From b3d8c5ba991192f1cd50fe57abb93466bc8d18bc Mon Sep 17 00:00:00 2001 From: Jeena Paradies Date: Mon, 21 Feb 2011 15:43:39 +0100 Subject: [PATCH 1/3] added more test --- src/ggs_gamevm.erl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ggs_gamevm.erl b/src/ggs_gamevm.erl index 6493c9f..acfe2fb 100644 --- a/src/ggs_gamevm.erl +++ b/src/ggs_gamevm.erl @@ -120,3 +120,9 @@ user_command_test() -> user_command(GameVM, "'jeena", "thecommand", "theargs'"), ?assertMatch(<<"'jeenathecommandtheargs'">>, gen_server:call(GameVM, {eval, "t;"})). +user_command2_test() -> + GameVM = start_link(test_table), + define(GameVM, "var t = '';\nfunction userCommand(user, command, args) { t = callErlang('erlang time') + ''; }\n"), + user_command(GameVM, "jeena", "test", ""), + io:format("test ~p~n", [binary_to_list(gen_server:call(GameVM, {eval, "t;"}))]), + ?assertMatch(<<"rt">>, gen_server:call(GameVM, {eval, "t;"})). From 08e0be70e2c15446ebac33aba64d66b95093cfe2 Mon Sep 17 00:00:00 2001 From: Jeena Paradies Date: Mon, 21 Feb 2011 20:54:43 +0100 Subject: [PATCH 2/3] fixed test with js callback --- erlang_js | 2 +- src/ggs_gamevm.erl | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/erlang_js b/erlang_js index 5350ed2..2f2785f 160000 --- a/erlang_js +++ b/erlang_js @@ -1 +1 @@ -Subproject commit 5350ed21606606dbee5ecb07e974f2abb9106270 +Subproject commit 2f2785fafb0da6db75810eb6fa97d09c58257588 diff --git a/src/ggs_gamevm.erl b/src/ggs_gamevm.erl index acfe2fb..294eb10 100644 --- a/src/ggs_gamevm.erl +++ b/src/ggs_gamevm.erl @@ -119,10 +119,15 @@ user_command_test() -> define(GameVM, "var t = '';\nfunction userCommand(user, command, args) { t = user + command + args; }\n"), user_command(GameVM, "'jeena", "thecommand", "theargs'"), ?assertMatch(<<"'jeenathecommandtheargs'">>, gen_server:call(GameVM, {eval, "t;"})). + +to_string({A, B, C}) -> + "{" ++ integer_to_list(A) ++ ", " ++ integer_to_list(B) ++ ", " ++ integer_to_list(C) ++ "}". user_command2_test() -> GameVM = start_link(test_table), define(GameVM, "var t = '';\nfunction userCommand(user, command, args) { t = callErlang('erlang time') + ''; }\n"), - user_command(GameVM, "jeena", "test", ""), - io:format("test ~p~n", [binary_to_list(gen_server:call(GameVM, {eval, "t;"}))]), - ?assertMatch(<<"rt">>, gen_server:call(GameVM, {eval, "t;"})). + user_command(GameVM, "", "", ""), + T = to_string(erlang:time()), + io:format("test ~p~n", [T]), + ?assertMatch(T, binary_to_list(gen_server:call(GameVM, {eval, "t;"}))). + From e03f3cf69d475b2aa90a133cdd39835dcc3c1781 Mon Sep 17 00:00:00 2001 From: Jeena Paradies Date: Tue, 22 Feb 2011 00:15:21 +0100 Subject: [PATCH 3/3] better js_erlang_test --- src/ggs_gamevm.erl | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/ggs_gamevm.erl b/src/ggs_gamevm.erl index 294eb10..6dd19a7 100644 --- a/src/ggs_gamevm.erl +++ b/src/ggs_gamevm.erl @@ -120,14 +120,11 @@ user_command_test() -> user_command(GameVM, "'jeena", "thecommand", "theargs'"), ?assertMatch(<<"'jeenathecommandtheargs'">>, gen_server:call(GameVM, {eval, "t;"})). -to_string({A, B, C}) -> - "{" ++ integer_to_list(A) ++ ", " ++ integer_to_list(B) ++ ", " ++ integer_to_list(C) ++ "}". - -user_command2_test() -> +js_erlang_test() -> GameVM = start_link(test_table), define(GameVM, "var t = '';\nfunction userCommand(user, command, args) { t = callErlang('erlang time') + ''; }\n"), user_command(GameVM, "", "", ""), - T = to_string(erlang:time()), - io:format("test ~p~n", [T]), - ?assertMatch(T, binary_to_list(gen_server:call(GameVM, {eval, "t;"}))). + {A, B, C} = erlang:time(), + T = "{" ++ integer_to_list(A) ++ ", " ++ integer_to_list(B) ++ ", " ++ integer_to_list(C) ++ "}", + ?assertMatch(T, binary_to_list(gen_server:call(GameVM, {eval, "t;"}))).