added ggs_gamevm:
This commit is contained in:
parent
0aac25cd42
commit
191c464220
3 changed files with 12 additions and 17 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 5350ed21606606dbee5ecb07e974f2abb9106270
|
Subproject commit 709b568efbc99c954507d1593bc5633f900bc5dc
|
|
@ -1,5 +0,0 @@
|
||||||
%% gamedb.hrl
|
|
||||||
|
|
||||||
-record(data, {key, value}).
|
|
||||||
|
|
||||||
|
|
|
@ -3,28 +3,28 @@
|
||||||
|
|
||||||
start_link_test() ->
|
start_link_test() ->
|
||||||
erlang_js:start(), %% @TODO: should only be done once
|
erlang_js:start(), %% @TODO: should only be done once
|
||||||
GameVM = start_link(test_table),
|
GameVM = ggs_gamevm:start_link(test_table),
|
||||||
?assertNot(GameVM =:= undefined).
|
?assertNot(GameVM =:= undefined).
|
||||||
|
|
||||||
define_test() ->
|
define_test() ->
|
||||||
GameVM = start_link(test_table),
|
GameVM = ggs_gamevm:start_link(test_table),
|
||||||
define(GameVM, "function hello(test) { return test; }"),
|
ggs_gamevm:define(GameVM, "function hello(test) { return test; }"),
|
||||||
?assertMatch(<<"jeena">>, gen_server:call(GameVM, {eval, "hello('jeena')"})).
|
?assertMatch(<<"jeena">>, gen_server:call(GameVM, {eval, "hello('jeena')"})).
|
||||||
|
|
||||||
stop_test() ->
|
stop_test() ->
|
||||||
GameVM = start_link(test_table),
|
GameVM = ggs_gamevm:start_link(test_table),
|
||||||
ok = stop(GameVM).
|
ok = ggs_gamevm:stop(GameVM).
|
||||||
|
|
||||||
user_command_test() ->
|
user_command_test() ->
|
||||||
GameVM = start_link(test_table),
|
GameVM = ggs_gamevm:start_link(test_table),
|
||||||
define(GameVM, "var t = '';\nfunction userCommand(user, command, args) { t = user + command + args; }\n"),
|
ggs_gamevm:define(GameVM, "var t = '';\nfunction userCommand(user, command, args) { t = user + command + args; }\n"),
|
||||||
user_command(GameVM, "'jeena", "thecommand", "theargs'"),
|
ggs_gamevm:user_command(GameVM, "'jeena", "thecommand", "theargs'"),
|
||||||
?assertMatch(<<"'jeenathecommandtheargs'">>, gen_server:call(GameVM, {eval, "t;"})).
|
?assertMatch(<<"'jeenathecommandtheargs'">>, gen_server:call(GameVM, {eval, "t;"})).
|
||||||
|
|
||||||
js_erlang_test() ->
|
js_erlang_test() ->
|
||||||
GameVM = start_link(test_table),
|
GameVM = ggs_gamevm:start_link(test_table),
|
||||||
define(GameVM, "var t = '';\nfunction userCommand(user, command, args) { t = callErlang('erlang time') + ''; }\n"),
|
ggs_gamevm:define(GameVM, "var t = '';\nfunction userCommand(user, command, args) { t = callErlang('erlang time') + ''; }\n"),
|
||||||
user_command(GameVM, "", "", ""),
|
ggs_gamevm:user_command(GameVM, "", "", ""),
|
||||||
{A, B, C} = erlang:time(),
|
{A, B, C} = erlang:time(),
|
||||||
T = "{" ++ integer_to_list(A) ++ ", " ++ integer_to_list(B) ++ ", " ++ integer_to_list(C) ++ "}",
|
T = "{" ++ integer_to_list(A) ++ ", " ++ integer_to_list(B) ++ ", " ++ integer_to_list(C) ++ "}",
|
||||||
?assertMatch(T, binary_to_list(gen_server:call(GameVM, {eval, "t;"}))).
|
?assertMatch(T, binary_to_list(gen_server:call(GameVM, {eval, "t;"}))).
|
||||||
|
|
Reference in a new issue