Added two more Javascript tests.
- `abstract_inherit` - `char_strings`
This commit is contained in:
parent
571c516a0b
commit
e5ad9cdc05
2 changed files with 51 additions and 0 deletions
40
Examples/test-suite/javascript/abstract_inherit_runme.js
Normal file
40
Examples/test-suite/javascript/abstract_inherit_runme.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
var abstract_inherit = require("./abstract_inherit");
|
||||
|
||||
// Shouldn't be able to instantiate any of these classes
|
||||
// since none of them implements the pure virtual function
|
||||
// declared in the base class (Foo).
|
||||
var Foo = abstract_inherit.Foo;
|
||||
var Bar = abstract_inherit.Bar;
|
||||
var Spam = abstract_inherit.Spam;
|
||||
|
||||
var caughtException = false;
|
||||
try {
|
||||
new Foo();
|
||||
} catch (err) {
|
||||
caughtException = true;
|
||||
}
|
||||
if (!caughtException) {
|
||||
throw new Error("Foo should be instantiated as it is abstract");
|
||||
}
|
||||
|
||||
caughtException = false;
|
||||
try {
|
||||
new Bar();
|
||||
} catch (err) {
|
||||
caughtException = true;
|
||||
}
|
||||
|
||||
if (!caughtException) {
|
||||
throw new Error("Bar should be instantiated as it is abstract");
|
||||
}
|
||||
|
||||
caughtException = false;
|
||||
try {
|
||||
new Spam();
|
||||
} catch (err) {
|
||||
caughtException = true;
|
||||
}
|
||||
|
||||
if (!caughtException) {
|
||||
throw new Error("Spam should be instantiated as it is abstract");
|
||||
}
|
||||
11
Examples/test-suite/javascript/char_strings_runme.js
Normal file
11
Examples/test-suite/javascript/char_strings_runme.js
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
var char_strings = require("char_strings");
|
||||
|
||||
var assertIsEqual = function(expected, actual) {
|
||||
if (expected !== actual) {
|
||||
throw new Error("Expected "+expected+", was "+actual);
|
||||
}
|
||||
};
|
||||
|
||||
assertIsEqual("hi there", char_strings.CharPingPong("hi there"));
|
||||
assertIsEqual("hi there", char_strings.CharArrayPingPong("hi there"));
|
||||
assertIsEqual("hi there", char_strings.CharArrayDimsPingPong("hi there"));
|
||||
Loading…
Add table
Add a link
Reference in a new issue