Permalink
Browse files

Test file 2 will just be for args; add tests for float, double and st…

…ring passing.
  • Loading branch information...
1 parent 41aaf3d commit bee23d5a7d660f51639f39cfcf86435df86d9948 @jnthn committed Jan 13, 2012
Showing with 47 additions and 14 deletions.
  1. +0 −14 t/02-simple-args-and-returns.t
  2. +23 −0 t/{02-simple-args-and-returns.c → 02-simple-args.c}
  3. +24 −0 t/02-simple-args.t
@@ -1,14 +0,0 @@
-use t::CompileTestLib;
-use NativeCall;
-
-say "1..6";
-
-compile_test_lib('02-simple-args-and-returns');
-
-sub TakeInt(int32) is native('02-simple-args-and-returns') { * }
-sub TakeTwoShorts(int16, int16) is native('02-simple-args-and-returns') { * }
-sub AssortedIntArgs(int32, int16, int8) is native('02-simple-args-and-returns') { * }
-
-TakeInt(42);
-TakeTwoShorts(10, 20);
-AssortedIntArgs(101, 102, 103);
@@ -44,3 +44,26 @@ DLLEXPORT void AssortedIntArgs(int x, short y, char z)
printf("not ok 6 - got passed char 103\n", x);
fflush(stdout);
}
+
+DLLEXPORT void TakeADouble(double x)
+{
+ if (-6.9 - x < 0.001)
+ printf("ok 7 - got passed double -6.9\n", x);
+ else
+ printf("not ok 7 - got passed double -6.9\n", x);
+}
+
+DLLEXPORT void TakeAFloat(float x)
+{
+ if (4.2 - x < 0.001)
+ printf("ok 8 - got passed float 4.2\n", x);
+ else
+ printf("not ok 8 - got passed float 4.2\n", x);
+}
+
+DLLEXPORT void TakeAString(char *pass_msg)
+{
+ printf("%s\n", pass_msg);
+}
+
+
View
@@ -0,0 +1,24 @@
+use t::CompileTestLib;
+use NativeCall;
+
+say "1..9";
+
+compile_test_lib('02-simple-args');
+
+# Int related
+sub TakeInt(int32) is native('02-simple-args') { * }
+sub TakeTwoShorts(int16, int16) is native('02-simple-args') { * }
+sub AssortedIntArgs(int32, int16, int8) is native('02-simple-args') { * }
+TakeInt(42);
+TakeTwoShorts(10, 20);
+AssortedIntArgs(101, 102, 103);
+
+# Float related
+sub TakeADouble(num64) is native('02-simple-args') { * }
+sub TakeAFloat(num32) is native('02-simple-args') { * }
+TakeADouble(-6.9e0);
+TakeAFloat(4.2e0);
+
+# String related
+sub TakeAString(Str) is native('02-simple-args') { * }
+TakeAString('ok 9 - passed a string');

0 comments on commit bee23d5

Please sign in to comment.