Mercurial > web-gnusto
changeset 12:a0c7b17ae1c6
Added more functionality to engine runner, testing suite
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Sun, 11 May 2008 15:52:18 -0700 |
parents | 08983db95420 |
children | ba38424a14c2 |
files | engine-runner.js tests/output/test_engine_runner.txt tests/output/test_gnusto_engine.txt tests/test_engine_runner.js tests/test_gnusto_engine.js |
diffstat | 5 files changed, 83 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/engine-runner.js Sun May 11 14:28:29 2008 -0700 +++ b/engine-runner.js Sun May 11 15:52:18 2008 -0700 @@ -36,6 +36,8 @@ }, onGetCursor: function() { }, + onPrint: function(output) { + }, onPrintTable: function(lines) { }, }; @@ -111,6 +113,9 @@ case GNUSTO_EFFECT_PIRACY: break; case GNUSTO_EFFECT_STYLE: + self._zui.onSetStyle(engine.effect(1), + engine.effect(2), + engine.effect(3)); break; case GNUSTO_EFFECT_SOUND: break; @@ -134,6 +139,10 @@ break; } + var text = engine.consoleText(); + if (text) + self._zui.onPrint(text); + self._isInLoop = false; } };
--- a/tests/output/test_engine_runner.txt Sun May 11 14:28:29 2008 -0700 +++ b/tests/output/test_engine_runner.txt Sun May 11 15:52:18 2008 -0700 @@ -1,6 +1,8 @@ onLineInput() received responding immediately with: hello engine.answer() received: 1, hello +onSetStyle() received: style:0 fg:0 bg:0 +onPrint() received: Hai2u! onLineInput() received queuing delayed response: hello again Calling delayed call
--- a/tests/output/test_gnusto_engine.txt Sun May 11 14:28:29 2008 -0700 +++ b/tests/output/test_gnusto_engine.txt Sun May 11 15:52:18 2008 -0700 @@ -1,4 +1,5 @@ -[SS] +[GNUSTO_EFFECT_STYLE 2 0 0] + @@ -7,8 +8,10 @@ -[SS] Zork: A Troll's Eye View -[SS] +[GNUSTO_EFFECT_STYLE 0 0 0] +Zork: A Troll's Eye View +[GNUSTO_EFFECT_STYLE 2 0 0] + An Interactive Tedium by Dylan O'Donnell (dylanw@demon.net) Type "info" for the story behind it. @@ -16,28 +19,33 @@ Release 3 / Serial number 980518 / Inform v6.15 Library 6/7 -[SS] The Troll Room -[TW] +[GNUSTO_EFFECT_STYLE 0 0 0] +The Troll Room +[TW] + This is a small room with passages to the east and south and a forbidding hole leading west. Bloodstains and deep scratches (perhaps made by an axe) mar the walls. > -[SW] -[SC] -[SS] -[SC] -[SC] The Troll Room -[SS] -[SW] -[RS] +[SW] +[SC] +[GNUSTO_EFFECT_STYLE 1 0 0] +[SC] +[SC] +The Troll Room +[GNUSTO_EFFECT_STYLE 0 0 0] +[SW] responding with "quit" -[TW] Are you sure you want to quit? -[SW] -[SC] -[SS] -[SC] -[SC] The Troll Room -[SS] -[SW] -[RS] +[GNUSTO_EFFECT_INPUT] +[TW] +Are you sure you want to quit? +[SW] +[SC] +[GNUSTO_EFFECT_STYLE 1 0 0] +[SC] +[SC] +The Troll Room +[GNUSTO_EFFECT_STYLE 0 0 0] +[SW] responding with "yes" -[QU] +[GNUSTO_EFFECT_INPUT] +[QU]
--- a/tests/test_engine_runner.js Sun May 11 14:28:29 2008 -0700 +++ b/tests/test_engine_runner.js Sun May 11 15:52:18 2008 -0700 @@ -10,26 +10,34 @@ self._step += 1; }, - effect: function() { - var effect; + effect: function(which) { + var effects = [ + [GNUSTO_EFFECT_INPUT], + [GNUSTO_EFFECT_STYLE, 0, 0, 0], + [GNUSTO_EFFECT_INPUT], + [GNUSTO_EFFECT_QUIT] + ]; - switch (self._step) { - case 1: - case 2: - effect = GNUSTO_EFFECT_INPUT; - break; - case 3: - effect = GNUSTO_EFFECT_QUIT; - break; - default: - throw Error('Unexpected step'); - } + var effect = effects[self._step-1][which]; - return effect.slice(1, -1); + if (which == 0) + effect = effect.slice(1, -1); + + return effect; }, answer: function(number, response) { print("engine.answer() received: "+number+", "+response); + }, + + consoleText: function() { + switch (self._step) { + case 2: + return "Hai2u!"; + break; + default: + return ""; + } } }; } @@ -56,6 +64,15 @@ gDelayedCallQueue.push(function() { callback(response); }); } self._inputCount += 1; + }, + + onPrint: function(text) { + print("onPrint() received: "+text); + }, + + onSetStyle: function(textStyle, foreground, background) { + print("onSetStyle() received: style:" + textStyle + + " fg:" + foreground + " bg:" + background); } }; };
--- a/tests/test_gnusto_engine.js Sun May 11 14:28:29 2008 -0700 +++ b/tests/test_gnusto_engine.js Sun May 11 15:52:18 2008 -0700 @@ -8,7 +8,7 @@ engine.run(); var effect = engine.effect(0); var text = engine.consoleText(); - print('['+effect+'] '+text); + var desc = '['+effect+']'; effect = '"' + effect + '"'; @@ -16,10 +16,15 @@ case GNUSTO_EFFECT_INPUT: var responses = ['quit', 'yes']; var response = responses[gInputTimes]; + desc = '[GNUSTO_EFFECT_INPUT]'; print('responding with "' + response + '"'); engine.answer(1, response); gInputTimes += 1; break; + case GNUSTO_EFFECT_STYLE: + desc = ('[GNUSTO_EFFECT_STYLE ' + engine.effect(1) + + ' ' + engine.effect(2) + ' ' + engine.effect(3) + ']'); + break; case GNUSTO_EFFECT_QUIT: retval = 1; break; @@ -27,6 +32,10 @@ break; }; + print(desc); + if (text) + print(text); + return retval; }