Debian Codegraph @

tests/reproducers/simple/JSToJGet/resources/JSToJ_auxiliary.js

raw
1 /*
2 JSToJ_auxiliary.js
3 This file contains auxiliary JavaScript functions for LiveConnect tests output
4 it is used by JSToJGet reproducer.
5 */
6
7 function check(actual, expected, expectedtype, testid, appletName ) {
8 if (actual == expected) { //the same value
9 if (typeof(actual) == expectedtype) { //the same type
10 passTest( testid, appletName );
11 } else {
12 failTypeTest( testid, appletName, actual, expectedtype );
13 }
14 } else {
15 failValTest( testid, appletName, actual, expected );
16 }
17 }
18
19 function passTest( testid, appletName ){
20 var passStr = "Test no."+testid+" - passed.";
21 //applet stdout
22 appletStdOut( appletName, passStr);
23 //html page
24 appendMessageDiv(passStr);
25 }
26
27 function failValTest( testid, appletName, actual, expected ){
28 var failValStr = "Test no."+testid+" - failed, value mismatch. expected:["+expected+"] found:["+actual+"].";
29 //applet stdout
30 appletStdOut( appletName, failValStr);
31 //html page
32 appendMessageDiv(failValStr);
33 }
34
35 function failTypeTest( testid, appletName, actual, expectedtype ){
36 var failTypeStr = "Test no."+testid+" - failed, type mismatch. expected:["+expectedtype+"] found:["+typeof(actual)+"].";
37 //applet stdout
38 appletStdOutLn( appletName, failTypeStr);
39 //html page
40 appendMessageDiv(failTypeStr);
41 }
42
43 function appletStdOut( appletName, str ){
44 appletName.stdOutWrite( str );
45 }
46
47 function appletStdOutLn( appletName, str ){
48 appletName.stdOutWriteln( str );
49 }
50
51 function afterTestsMessage( appletName ){
52 appletName.stdOutWriteln("afterTests");
53 }
54
55 function appendMessageDiv( message ){
56 var messageDiv = document.getElementById( 'messageDiv' );
57 messageDiv.appendChild( document.createTextNode(message) );
58 }