summaryrefslogtreecommitdiff
path: root/Examples/test-suite/javascript/abstract_inherit_runme.js
blob: f732e87673384823ef285e00faa27c31c79f853e (plain)
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
33
34
35
36
37
38
39
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");
}