File: test_kst.js

package info (click to toggle)
kst 2.0.8-6
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 30,748 kB
  • sloc: cpp: 97,086; ansic: 13,364; python: 2,970; sh: 761; yacc: 184; lex: 143; makefile: 141; javascript: 122; perl: 30; xml: 30
file content (59 lines) | stat: -rw-r--r-- 1,267 bytes parent folder | download | duplicates (10)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
Test bind_kst
*/

// Can't resetInterpreter because it nukes the script, of course...
//try { Kst.resetInterpreter(); } catch(e) { alert("Error: " + e.name); }

var errors = 0;
function assertNoReturn(x) {
	try {
		eval(x);
	} catch (e) {
		alert("Error: " + e.name + "\nLast test was: " + x);
		++errors;
	}
}


function assert(x) {
	try {
		var xrc = eval(x);
		if (!xrc) {
			alert("Failed: " + x);
			++errors;
		}
	} catch (e) {
		alert("Error: " + e.name + "\nLast test was: " + x);
		++errors;
	}
}

assertNoReturn("Kst.purge()");

assert("Kst.vectors.length == 0");
assert("Kst.scalars.length >= 0"); // the built-ins
assert("Kst.strings.length == 0");
assert("Kst.windows.length <= 1");
assert("Kst.dataSources.length == 0");

var v = new Vector;
v.tagName = "My Vector";
assert("Kst.vectors.length == 1");
assert("var j = Kst.vectors[0]; j.tagName = 'My Vector'");
assert("Kst.vectors[0].tagName = 'My Vector'");

var sc = Kst.scalars.length;
var s = new Scalar;
s.tagName = "My Scalar";
assert("Kst.scalars.length == " + (sc + 1));
assert("var j = Kst.scalars[0]; j.tagName = 'My Scalar'");
assert("Kst.scalars[" + sc + "].tagName = 'My Scalar'");



if (errors > 0) {
	alert("" + errors + " failed testcases.");
} else {
	alert("All tests passed.");
}