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

testsuite.js (6 issues)

1
/**
2
 * TestSuite Definition
3
 */
4
var testsuite = {
5
    code:
6
    "./dist/joii.js",
7
    tests: [
8
        // PrototypeBuilder
9
        "./test/PrototypeBuilder/DeepCopyTest.js",
10
        "./test/PrototypeBuilder/InheritanceTest.js",
11
        "./test/PrototypeBuilder/PropertyMetaTest.js",
12
        "./test/PrototypeBuilder/TraitTest.js",
13
        // ClassBuilder
14
        "./test/ClassBuilder/InstantiationTest.js",
15
        "./test/ClassBuilder/InheritanceTest.js",
16
        "./test/ClassBuilder/AbstractImplementationTest.js",
17
        "./test/ClassBuilder/VisibilityTest.js",
18
        "./test/ClassBuilder/GetterTest.js",
19
        "./test/ClassBuilder/SetterValidationTest.js",
20
        "./test/ClassBuilder/NullableTypeTest.js",
21
        "./test/ClassBuilder/TypeValidationTest.js",
22
        "./test/ClassBuilder/InstanceOfTest.js",
23
        "./test/ClassBuilder/CallTest.js",
24
        "./test/ClassBuilder/ConstantTest.js",
25
        "./test/ClassBuilder/SerializeTest.js",
26
        "./test/ClassBuilder/FunctionOverloadingTests.js",
27
        // InterfaceBuilder,
28
        "./test/InterfaceBuilder/InterfaceBuilderTest.js",
29
        "./test/InterfaceBuilder/InterfaceValidationTest.js",
30
        // EnumBuilder
31
        "./test/EnumBuilder/EnumBuilderTest.js",
32
        // Reflection
33
        "./test/Reflection/ReflectionTest.js",
34
        // GitHub Reported Issues
35
        "./test/IssueReports/IssueReport4.js",
36
        "./test/IssueReports/IssueReport9.js",
37
        "./test/IssueReports/IssueReport10.js",
38
        "./test/IssueReports/IssueReport11.js",
39
        "./test/IssueReports/IssueReport15.js",
40
        "./test/IssueReports/IssueReport16.js",
41
        "./test/IssueReports/IssueReport19.js",
42
        "./test/IssueReports/IssueReport21.js",
43
        "./test/IssueReports/IssueReport25.js"
44
    ]
45
};
46
47
/**
48
 * Platform-independent bootstrap.
49
 */
50
if (typeof (window) !== 'object' || window === undefined) {
51
    // Are we running on CLI / NodeJS ?
52
    var qunit = require("qunit");
53
    qunit.run(testsuite);
54
} else {
55
    // We're running a browser.
56
57
    // change to src version
58
    testsuite.code = [
59
        'src/Compatibility.js',
60
        'src/PrototypeBuilder.js',
61
        'src/ClassBuilder.js',
62
        'src/InterfaceBuilder.js',
63
        'src/EnumBuilder.js',
64
        'src/Reflection.js',
65
        'src/Config.js',
66
        'src/joii.js'
67
    ];
68
69
70
    // ensure that all scripts load in the right order, so that the tests have the same ordinal each time
71
    var loaded_scripts = 0;
72
    var total_scripts = testsuite.tests.length;
73
74
    var all_scripts_to_load = [];
75
76
    var array_index = 0;
77
78
    if (typeof (testsuite.code) === 'object') {
79
        total_scripts += testsuite.code.length;
80
        all_scripts_to_load = testsuite.code.slice(0);
81
    }
82
    else {
83
        total_scripts++;
84
        all_scripts_to_load.push(testsuite.code);
85
    }
86
87
    Array.prototype.push.apply(all_scripts_to_load, testsuite.tests);
88
89
90
    var loadNextScript = function(file) {
91
        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...
92
            addScript(all_scripts_to_load[array_index]);
93
            array_index++;
94
        }
95
    };
96
97
    var addScript = function(file) {
0 ignored issues
show
'addScript' was used before it was defined.
Loading history...
98
        var s = document.createElement('script');
99
        s.setAttribute('type', 'text/javascript');
100
        s.setAttribute('src', file);
101
        s.onload = function() {
102
            loaded_scripts++;
103
            loadNextScript();
104
        };
105
        document.getElementsByTagName('head')[0].appendChild(s);
106
    };
107
108
    var require = function() {
0 ignored issues
show
Redefinition of 'require'.
Loading history...
'require' was used before it was defined.
Loading history...
109
        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...
110
    }
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...
111
112
    loadNextScript();
113
}