Skip to content

Commit

Permalink
Add some test runners.
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver7654 committed Sep 23, 2013
1 parent b9ecf75 commit 2efe63e
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Examples/test-suite/javascript/callback_runme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
var callback = require("./callback");

if (callback.foo(2) !== 2) {
throw new Error("Failed.");
}
if (callback.A_bar(2) !== 4) {
throw new Error("Failed.");
}
if (callback.foobar(3, callback.foo) != callback.foo(3)) {
throw new Error("Failed.");
}
if (callback.foobar(3, foo) != callback.foo(3)) {
throw new Error("Failed.");
}
if (callback.foobar(3, callback.A_bar) != callback.A_bar(3)) {
throw new Error("Failed.");
}
if (callback.foobar(3, callback.foof) != callback.foof(3)) {
throw new Error("Failed.");
}
if (callback.foobar_i(3, callback.foo_i) != callback.foo_i(3)) {
throw new Error("Failed.");
}
if (callback.foobar_d(3.5, callback.foo_d) != callback.foo_d(3.5)) {
throw new Error("Failed.");
}
var a = new callback.A();
if (callback.foobarm(3, a, callback.A.foom_cb_ptr) != a.foom(3)) {
throw new Error("Failed.");
}
22 changes: 22 additions & 0 deletions Examples/test-suite/javascript/disown_runme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var disown = require("./disown");

var a = new disown.A();
var tmp = a.thisown;
a.thisown = 0
if (a.thisown) {
throw new Error("Failed.");
}
a.thisown = 1
if (!a.thisown) {
throw new Error("Failed.");
}
a.thisown = tmp
if (a.thisown != tmp) {
throw new Error("Failed.");
}

var b = new disown.B();
b.acquire(a);
if (a.thisown) {
throw new Error("Failed.");
}
12 changes: 12 additions & 0 deletions Examples/test-suite/javascript/dynamic_cast_runme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var dynamic_cast = require("./dynamic_cast");

var f = new dynamic_cast.Foo();
var b = new dynamic_cast.Bar();

var x = f.blah();
var y = b.blah();

var a = dynamic_cast.do_test(y);
if (a != "Bar::test") {
throw new Error("Failed.");
}
1 change: 1 addition & 0 deletions Examples/test-suite/javascript/empty_runme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var empty = require("./empty");
44 changes: 44 additions & 0 deletions Examples/test-suite/javascript/varargs_runme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
var varargs = require("./varargs");

if (varargs.test("Hello") != "Hello") {
throw new Error("Failed");
}

var f = new varargs.Foo("Greetings")
if (f.str != "Greetings") {
throw new Error("Failed");
}

if (f.test("Hello") != "Hello") {
throw new Error("Failed");
}

if (varargs.test_def("Hello",1) != "Hello") {
throw new Error("Failed");
}

if (varargs.test_def("Hello") != "Hello") {
throw new Error("Failed");
}

if (varargs.test_plenty("Hello") != "Hello") {
throw new Error("Failed");
}

if (varargs.test_plenty("Hello", 1) != "Hello") {
throw new Error("Failed");
}

if (varargs.test_plenty("Hello", 1, 2) != "Hello") {
throw new Error("Failed");
}

var thrown = false;
try {
varargs.test_plenty("Hello", 1, 2, 3);
} catch (err) {
thrown = true;
}
if (!thrown) {
throw new Error("Failed");
}

0 comments on commit 2efe63e

Please sign in to comment.