OLD | NEW |
(Empty) | |
| 1 let {Logger} = require( "logger" ); |
| 2 let {Encoding} = require( "encoding" ); |
| 3 let {Action} = require( "action" ); |
| 4 |
| 5 var what = "actions"; |
| 6 var output_box; |
| 7 function sandbox_start() |
| 8 { |
| 9 output_box = document.getElementById( "sandbox_output" ); |
| 10 switch ( what ) |
| 11 { |
| 12 case "actions": |
| 13 exercise_actions(); |
| 14 break; |
| 15 } |
| 16 } |
| 17 |
| 18 var write = function( s ) |
| 19 { |
| 20 output_box.value += s; |
| 21 }; |
| 22 |
| 23 var logger = new Logger( "sandbox" ); |
| 24 var log = logger.make_log(); |
| 25 |
| 26 //==============================================================================
=========== |
| 27 // exercise_actions |
| 28 //==============================================================================
=========== |
| 29 function exercise_actions() |
| 30 { |
| 31 log( "Action" ); |
| 32 |
| 33 //----------------------------------------------------------------------------
------------- |
| 34 write( "---\n" ); |
| 35 write( "# 0\n" ); |
| 36 var t = typeof Action; |
| 37 write( "Action is " + ((t === 'undefined') ? "not " : "") + "defined." |
| 38 + " It is " + ((t === 'object') ? "" : "not") + "an object.\n" ); |
| 39 var b = "Join" in Action; |
| 40 write( "Action.Join is a " + (b ? "valid " : "invalid") + "member.\n" ); |
| 41 |
| 42 //----------------------------------------------------------------------------
------------- |
| 43 write( "---\n" ); |
| 44 write( "# 1\n" ); |
| 45 var defer = new Action.Defer( function() |
| 46 { |
| 47 write( "Defer executed." ) |
| 48 } ); |
| 49 |
| 50 function catcher() |
| 51 { |
| 52 write( "Join_Timeout catcher: timed_out = " + join.timed_out + ".\n" ); |
| 53 } |
| 54 |
| 55 function finisher() |
| 56 { |
| 57 write( "Finished." ); |
| 58 } |
| 59 |
| 60 try |
| 61 { |
| 62 var join = new Action.Join_Timeout( defer, 10 ); |
| 63 join.go( finisher, catcher ); |
| 64 } |
| 65 catch ( e ) |
| 66 { |
| 67 write( "Exception: " + e.message ); |
| 68 } |
| 69 |
| 70 } |
| 71 |
OLD | NEW |