Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1771)

Side by Side Diff: js/tests/object.js

Issue 1204793003: Add tests for sk.object functions and sk.stateReflector. (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | js/tests/stateReflector.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 describe('sk.object functions',
2 function() {
3 function testGetDelta() {
4 var test = function(o, d, expected) {
5 assert.deepEqual(sk.object.getDelta(o, d), expected);
6 }
7 test({}, {}, {});
8 test({a: "foo"}, {a: "foo"}, {});
9 var first = {}; // Ensure getDelta does not modify its arguments.
10 test(first, {a: "foo"}, {});
11 assert.deepEqual(first, {});
12 var second = {}; // Ensure getDelta does not modify its arguments.
13 test({a: "foo"}, second, {a: "foo"});
14 assert.deepEqual(second, {});
15 test({a: "foo"}, {a: "bar"}, {a: "foo"});
16 test({a: "foo", b: "bar"}, {a: true, c: "bar"}, {a: "foo", b: "bar"});
17 test(["one", 2, 3.0], [1, "2", 3], {'0': "one"});
18 test({a: undefined, b: NaN, c: null}, {a: true, b: true, c: true},
19 {a: undefined, b: NaN, c: null});
20 test({a: undefined, b: NaN, c: false}, {a: null, b: null, c: null},
21 {b: NaN, c: false});
22 var noop = function () {};
23 test({a: test, b: noop}, {a: test, b: function () {}}, {b: noop});
24 }
25
26 function testApplyDelta() {
27 var test = function(delta, o, expected) {
28 assert.deepEqual(sk.object.applyDelta(delta, o), expected);
29 }
30 test({}, {}, {});
31 test({}, {a: "foo"}, {a: "foo"});
32 var first = {a: "bar"}; // Ensure applyDelta does not modify its argument s.
33 test(first, {a: "foo"}, {a: "bar"});
34 assert.deepEqual(first, {a: "bar"});
35 var second = {a: "bar"}; // Ensure applyDelta does not modify its argumen ts.
36 test({a: "foo"}, second, {a: "foo"});
37 assert.deepEqual(second, {a: "bar"});
38 test({a: "foo"}, {a: "bar", b: "baz"}, {a: "foo", b: "baz"});
39 test({a: "foo", b: "baz"}, {a: "bar"}, {a: "foo"});
40 test({a: "foo", b: "bar"}, {a: true, c: "bar"},
41 {a: "foo", c: "bar"});
42 test(["one"], [1, "2", 3], {'0': "one", '1': "2", '2': 3});
43 test({b: NaN, c: false}, {a: null, b: null, c: null},
44 {a: null, b: NaN, c: false});
45 }
46
47 it('should be able get differences and apply differences', function() {
48 testGetDelta();
49 testApplyDelta();
50 });
51 }
52 );
OLDNEW
« no previous file with comments | « no previous file | js/tests/stateReflector.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698