aboutsummaryrefslogtreecommitdiffstats
path: root/tests/reproducers/simple/JSToJGet/resources/JSToJ_auxiliary.js
blob: 97231fe2fef58c0ee51caff6f9426939e840142d (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
JSToJ_auxiliary.js
This file contains auxiliary JavaScript functions for LiveConnect tests output,
the following reproducers have this file as a common resource:
- JSToJGet
- JSToJSet
- JSToJFuncParam
- JSToJFuncReturn
- JSToJFuncResol
- JSToJTypeConv
- JToJSGet
- JToJSSet
- JToJSFuncParam
- JToJSFuncReturn
- JToJSEval
*/

function check(actual, expected, expectedtype, testid, appletName ) {
    if (actual == expected) { //the same value
        if (typeof(actual) == expectedtype) { //the same type
            passTest( testid, appletName );
        } else {
            failTypeTest( testid, appletName, actual, expectedtype );
        }
    } else {
        failValTest( testid, appletName, actual, expected );                    
    }
}

function passTest( testid, appletName ){
    var passStr = "Test no."+testid+" - passed.";
    //applet stdout
    appletStdOut( appletName, passStr);
    //html page
    appendMessageDiv(passStr);
}

function failValTest( testid, appletName, actual, expected ){
    var failValStr = "Test no."+testid+" - failed, value mismatch. expected:["+expected+"] found:["+actual+"].";
    //applet stdout
    appletStdOut( appletName, failValStr);
    //html page
    appendMessageDiv(failValStr);
}

function failTypeTest( testid, appletName, actual, expectedtype ){
    var failTypeStr = "Test no."+testid+" - failed, type mismatch. expected:["+expectedtype+"] found:["+typeof(actual)+"].";
    //applet stdout
    appletStdOutLn( appletName, failTypeStr);
    //html page
    appendMessageDiv(failTypeStr);
}

function appletStdOut( appletName, str ){
    document.getElementById( appletName ).stdOutWrite( str );
}

function appletStdOutLn( appletName, str ){
    document.getElementById( appletName ).stdOutWriteln( str );
}

function afterTestsMessage( appletName ){
    document.getElementById( appletName ).stdOutWriteln("afterTests");
}

function appendMessageDiv( message ){
    var messageDiv = document.getElementById( 'messageDiv' );
    messageDiv.appendChild( document.createTextNode(message) );
}