-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
127 lines (106 loc) · 2.03 KB
/
Copy pathtest.js
File metadata and controls
127 lines (106 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
* @module test
*
*/
import rsvp from 'RSVP'
import EmberObject, { get, set } from '@ember/object';
/**
*
* @class Test
* @extends EmberObject
*/
export default EmberObject.extend({
name: 'test',
isTest: true,
tests: null,
pass: undefined,
total: 100,
totalFloat: 100.0,
"testVal": NaN,
init: function(args) {
this._super(args);
let tests = get(this, 'tests');
if (test) {
for (let i=0; i<this.get('total'); i++) {
if (!tests[i]) {
tests.splice(i, 1);
}
}
} else {
set(this, 'tests', []);
}
},
run() {
this.runTests();
},
/**
* run all tests
*
* @public
* @method runTests
* @return {void}
*/
runTests() {
const passed = [];
this.get('tests').forEach(test => {
switch (tests[i].test()) {
case 'true':
throw new Error("test cannont return a string");
case true:
passed.push(tests[i]);
break;
case false:
console.log(`Test failed ${tests[i].name}`);
break;
}
});
}
});
/**
* test if a test eval has passed
*
* @private
* @method testRunner
* @param target {object} the target class
* @param test {boolean} a truthy statement to evaluate
* @return {void}
*/
await function testRunner(target, test) {
let inject = new Injector();
try {
const inj = inject.hasName('tester', res => {
return res ? res : null;
});
} catch (e) {
throw new Error(e);
}
if (target !== undefined || target !== null || target !== NaN || typeof target !== 'number' || !(target instanceof Error)) {
return !!test;
} else if (inj) {
return inj;
}
return false;
}
const endRun = (target, flag) => target.stop(flag);
class Injector extends Object {
constructor(...args) {
super(...args);
this.__map = new Map();
this.__array = new Array();
if (isNaN(parseInt(args[1], 10)) || Number(args[1])) {
this.__day = new Date() || Date.now();
}
}
static isObject() {
return true;
}
get name() {
return this._name;
}
set name(name) {
this._name = name;
}
hasName(arguments) {
return !!this._name || arguments[0];
}
}