1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | var l8 = require( "l8/lib/node_server.js" )
|
10 | l8.http_port = parseInt( process.env.PORT, 10) || 8080
|
11 | l8.node_api_server( l8.http_port, "no credentials" )
|
12 |
|
13 |
|
14 | require( "l8/lib/node_client.js" )
|
15 | l8.node_api_client( "http://localhost:" + l8.http_port, "no credentials" )
|
16 |
|
17 |
|
18 | l8.task( function(){
|
19 |
|
20 |
|
21 |
|
22 | var fs
|
23 | var Buffer
|
24 | var fd
|
25 |
|
26 | l8.step( function ( ) { l8.require( "fs" );
|
27 | }).step( function (m) { fs = m;
|
28 | l8.require( "buffer" );
|
29 | }).step( function (m) { Buffer = m.Buffer;
|
30 | fs.open( "node.js.test_file.txt", "w" );
|
31 | }).step( function (f) { fd = f;
|
32 | new Buffer( "Hello, world!", "utf8" );
|
33 | }).step( function (b) { fs.write( fd, b, 0, b.length, null );
|
34 | }).step( function ( ) { fs.close( fd );
|
35 | }).step( function ( ) { fs.readFile( "node.js.test_file.txt", "utf8" );
|
36 | }).step( function (r) { l8.assert( r === "Hello, world!" );
|
37 | l8.trace( "TEST SUCCESS");
|
38 | process.exit( 0 )
|
39 | }).failure( function (e) { l8.trace( "Unexpected error", e, e.stack ); })
|
40 |
|
41 | })
|
42 |
|
43 | l8.countdown( 100 )
|
44 |
|