forked from joeferner/node-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstanceof-test.js
32 lines (28 loc) · 861 Bytes
/
instanceof-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var java = require("../testHelpers").java;
var nodeunit = require("nodeunit");
var util = require("util");
exports['instanceOf'] = nodeunit.testCase({
"working": function(test) {
var subclass = java.newInstanceSync("Test$SubClass");
if (!java.instanceOf(subclass, "Test$SuperClass")) {
test.fail(subclass.getNameSync() + " should be an instance of Test$SuperClass");
}
test.done();
},
"non-java object": function(test) {
if (java.instanceOf({}, "Test$SuperClass")) {
test.fail("javascript objects are not instances of anything");
}
test.done();
},
"bad type": function(test) {
var subclass = java.newInstanceSync("Test$SubClass");
try {
java.instanceOf(subclass, "BadClassName");
test.fail("should have thrown an exception.")
} catch (e) {
// OK
}
test.done();
}
});