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
|
var TEST_JS_LOADED // Purposfully left undefined - this is to avoid the global variables being loaded more than once
if (TEST_JS_LOADED == undefined) {
TEST_JS_LOADED = true
// Set to true to print out every single comparison
var verbose = false
// Set to true to "break" on the first error
var haltOnError = false
var errorCount = 0
function error(message) {
console.log("+++ " + message)
printBackTrace()
errorCount++
if ( haltOnError )
throw "error"
}
function printBackTrace() {
var bt = utils.backtrace()
// We start at 3, so we don't show backtrakce(), printBackTrace() and error()
for ( var i=3;i<bt.length;i++) {
console.log("\t" + bt[i])
}
}
function compare(act, exp, message) {
if ( verbose ) {
if ( message != undefined )
console.log("comparing(" + message + ") " + act + " with " + exp)
else
console.log("comparing " + act + " with " + exp)
}
if (act != exp) {
if ( message != undefined )
error("Compare failed (" + message +"): actual=" + act + " expected=" + exp)
else
error("Compare failed: actual=" + act + " expected=" + exp)
}
}
function comparePositions(act, exp, message) {
compare(act.line, exp.line, message)
compare(act.column, exp.column, message)
}
function verifyPosition(line,column, message) {
compare(editor.currentLine(), line, message)
compare(editor.currentColumn(), column, message)
}
}
|