Completed
Pull Request — master (#27)
by
unknown
48s
created

testsuite.js (6 issues)

1
/**
2
 * TestSuite Definition
3
 */
4
var testsuite = {
5
    code: "./dist/joii.js",
6
    tests: [
7
        // PrototypeBuilder
8
        "./test/PrototypeBuilder/DeepCopyTest.js",
9
        "./test/PrototypeBuilder/InheritanceTest.js",
10
        "./test/PrototypeBuilder/PropertyMetaTest.js",
11
        "./test/PrototypeBuilder/TraitTest.js",
12
        // ClassBuilder
13
        "./test/ClassBuilder/InstantiationTest.js",
14
        "./test/ClassBuilder/InheritanceTest.js",
15
        "./test/ClassBuilder/AbstractImplementationTest.js",
16
        "./test/ClassBuilder/VisibilityTest.js",
17
        "./test/ClassBuilder/GetterTest.js",
18
        "./test/ClassBuilder/SetterValidationTest.js",
19
        "./test/ClassBuilder/NullableTypeTest.js",
20
        "./test/ClassBuilder/TypeValidationTest.js",
21
        "./test/ClassBuilder/InstanceOfTest.js",
22
        "./test/ClassBuilder/CallTest.js",
23
        "./test/ClassBuilder/ConstantTest.js",
24
        "./test/ClassBuilder/SerializeTest.js",
25
        "./test/ClassBuilder/FunctionOverloadingTests.js",
26
        // InterfaceBuilder,
27
        "./test/InterfaceBuilder/InterfaceBuilderTest.js",
28
        "./test/InterfaceBuilder/InterfaceValidationTest.js",
29
        // EnumBuilder
30
        "./test/EnumBuilder/EnumBuilderTest.js",
31
        // Reflection
32
        "./test/Reflection/ReflectionTest.js",
33
        // GitHub Reported Issues
34
        "./test/IssueReports/IssueReport4.js",
35
        "./test/IssueReports/IssueReport9.js",
36
        "./test/IssueReports/IssueReport10.js",
37
        "./test/IssueReports/IssueReport11.js",
38
        "./test/IssueReports/IssueReport15.js",
39
        "./test/IssueReports/IssueReport16.js",
40
        "./test/IssueReports/IssueReport19.js",
41
        "./test/IssueReports/IssueReport21.js",
42
        "./test/IssueReports/IssueReport25.js"
43
    ]
44
};
45
46
/**
47
 * Platform-independent bootstrap.
48
 */
49
if (typeof (window) === 'undefined') {
50
    // Are we running on CLI / NodeJS ?
51
    var qunit = require("qunit");
52
    qunit.run(testsuite);
53
} else {
54
    // We're running a browser.
55
56
    // change to src version
57
    testsuite.code = [
58
        'src/Compatibility.js',
59
        'src/PrototypeBuilder.js',
60
        'src/ClassBuilder.js',
61
        'src/InterfaceBuilder.js',
62
        'src/EnumBuilder.js',
63
        'src/Reflection.js',
64
        'src/Config.js',
65
        'src/joii.js'
66
    ];
67
68
69
    // ensure that all scripts load in the right order, so that the tests have the same ordinal each time
70
    var loaded_scripts = 0;
71
    var total_scripts = testsuite.tests.length;
72
73
    var all_scripts_to_load = [];
74
75
    var array_index = 0;
76
77
    if (typeof (testsuite.code) === 'object') {
78
        total_scripts += testsuite.code.length;
79
        all_scripts_to_load = testsuite.code.slice(0);
80
    }
81
    else {
82
        total_scripts++;
83
        all_scripts_to_load.push(testsuite.code);
84
    }
85
86
    Array.prototype.push.apply(all_scripts_to_load, testsuite.tests);
87
88
89
    var loadNextScript = function(file) {
90
        if (array_index < all_scripts_to_load.length) {
0 ignored issues
show
This function should enable strict mode with use strict.

Strict mode is a way to opt-in to a restricted variant of JavaScript. It eliminates some common pitfalls by being less lenient and raising more errors.

Besides, it is also used to fix certain mistakes which made it difficult for JavaScript runtimes to perform certain optimizations.

We generally recommend to only enable strict mode on the function scope and not in the global scope as that might break third-party scripts on your website.

Loading history...
91
            addScript(all_scripts_to_load[array_index]);
92
            array_index++;
93
        }
94
    };
95
96
    var addScript = function(file) {
0 ignored issues
show
'addScript' was used before it was defined.
Loading history...
97
        var s = document.createElement('script');
98
        s.setAttribute('type', 'text/javascript');
99
        s.setAttribute('src', file);
100
        s.onload = function() {
101
            loaded_scripts++;
102
            loadNextScript();
103
        };
104
        document.getElementsByTagName('head')[0].appendChild(s);
105
    };
106
107
    var require = function() {
0 ignored issues
show
Redefinition of 'require'.
Loading history...
'require' was used before it was defined.
Loading history...
108
        return window;
0 ignored issues
show
This function should enable strict mode with use strict.

Strict mode is a way to opt-in to a restricted variant of JavaScript. It eliminates some common pitfalls by being less lenient and raising more errors.

Besides, it is also used to fix certain mistakes which made it difficult for JavaScript runtimes to perform certain optimizations.

We generally recommend to only enable strict mode on the function scope and not in the global scope as that might break third-party scripts on your website.

Loading history...
109
    }
0 ignored issues
show
There should be a semicolon.

Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.

Further Readings:

Loading history...
110
111
    loadNextScript();
112
}
113