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