Completed
Push — master ( 8f370e...b7ad0f )
by Harold
8s
created

testsuite.js (5 issues)

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