summaryrefslogtreecommitdiff
path: root/npc
diff options
context:
space:
mode:
Diffstat (limited to 'npc')
-rw-r--r--npc/dev/test.txt40
1 files changed, 40 insertions, 0 deletions
diff --git a/npc/dev/test.txt b/npc/dev/test.txt
index a9e78489a..c8c842055 100644
--- a/npc/dev/test.txt
+++ b/npc/dev/test.txt
@@ -116,6 +116,40 @@ function script F_TestVarOfAnotherNPC {
end;
}
+- script export test FAKE_NPC,{
+
+ function OnInit {
+ // functions labels should not be able to be called as events
+ // if a regression occurs, this function could end up being called when
+ // Hercules processes OnInit event calls (issue #2137)
+
+ // NOTE: If script_config.functions_as_events is enabled (defaults: off)
+ // and this this function is marked as public, it will trigger the
+ // warning and fail the unit test regardless.
+
+ $@something_bad_happened[0] = true;
+ end;
+ }
+
+ private function Private {
+ // function explicitly marked as private
+ return;
+ }
+
+ public function Public {
+ // this is for testing public local functions and ownership of the
+ // script
+
+ return getnpcid();
+ }
+
+ public function RefTest {
+ // this is to check if references are passed around properly
+
+ return set(getarg(0), 1337);
+ }
+}
+
function script HerculesSelfTestHelper {
if (.once > 0)
return .errors;
@@ -785,6 +819,12 @@ function script HerculesSelfTestHelper {
callsub(OnCheck, "data_to_string (string variable)", data_to_string(.@x$), ".@x$");
callsub(OnCheck, "data_to_string (integer variable)", data_to_string(.@x), ".@x");
+ "export test"::RefTest(.@refTest = 69);
+ callsub(OnCheck, "function as event (regression)", $@something_bad_happened[0], false);
+ callsub(OnCheck, "public local function ownership", "export test"::Public(), getnpcid());
+ callsub(OnCheck, "public local function var reference test", .@refTest, 1337);
+ callsub(OnCheck, "programatic public local call", callfunctionofnpc("export test", "RefTest", .@refTest = 1), 1337);
+
if (.errors) {
consolemes(CONSOLEMES_DEBUG, "Script engine self-test [ \033[0;31mFAILED\033[0m ]");
consolemes(CONSOLEMES_DEBUG, "**** The test was completed with " + .errors + " errors. ****");