/
props_helper.js
48 lines (39 loc) · 1.5 KB
/
props_helper.js
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
// used by unit tests to test both accessor mode and non-accessor mode
testBoth = function(testname, callback) {
function emberget(x,y) { return Ember.get(x,y); }
function emberset(x,y,z) { return Ember.set(x,y,z); }
function aget(x,y) { return x[y]; }
function aset(x,y,z) { return (x[y] = z); }
test(testname+' using Ember.get()/Ember.set()', function() {
callback(emberget, emberset);
});
test(testname+' using accessors', function() {
if (Ember.USES_ACCESSORS) callback(aget, aset);
else ok('SKIPPING ACCESSORS');
});
};
testWithDefault = function(testname, callback) {
function get(x,y) { return x.get(y); }
function emberget(x,y) { return Ember.get(x,y); }
function embergetwithdefault(x,y,z) { return Ember.getWithDefault(x,y,z); }
function getwithdefault(x,y,z) { return x.getWithDefault(y,z); }
function emberset(x,y,z) { return Ember.set(x,y,z); }
function aget(x,y) { return x[y]; }
function aset(x,y,z) { return (x[y] = z); }
test(testname+' using obj.get()', function() {
callback(emberget, emberset);
});
test(testname+' using obj.getWithDefault()', function() {
callback(getwithdefault, emberset);
});
test(testname+' using Ember.get()', function() {
callback(emberget, emberset);
});
test(testname+' using Ember.getWithDefault()', function() {
callback(embergetwithdefault, emberset);
});
test(testname+' using accessors', function() {
if (Ember.USES_ACCESSORS) callback(aget, aset);
else ok('SKIPPING ACCESSORS');
});
};