Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: test/tests/typedObjects.js

Issue 4827963358969856: Issue 147 - [Typed objects] Implement object types (Closed)
Left Patch Set: Created April 4, 2014, 10:28 a.m.
Right Patch Set: Fixed comments and one more issue Created April 22, 2014, 3:10 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « test/qunit.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 (function() 18 (function()
19 { 19 {
20 module("Typed objects"); 20 module("Typed objects");
21 21
22 test("Math utilities", function() 22 test("Math utilities", function()
23 { 23 {
24 let {ceilLog2, log2} = require("typedObjects/utils"); 24 let {nextPow2, ilog2} = require("typedObjects/utils");
25 25
26 equal(ceilLog2(0), 0, "ceilLog2(0)"); 26 equal(nextPow2(0), 0, "nextPow2(0)");
27 equal(ceilLog2(1), 1, "ceilLog2(1)"); 27 equal(nextPow2(1), 1, "nextPow2(1)");
28 equal(ceilLog2(2), 2, "ceilLog2(2)"); 28 equal(nextPow2(2), 2, "nextPow2(2)");
29 equal(ceilLog2(3), 4, "ceilLog2(3)"); 29 equal(nextPow2(3), 4, "nextPow2(3)");
30 equal(ceilLog2(7), 8, "ceilLog2(7)"); 30 equal(nextPow2(7), 8, "nextPow2(7)");
31 equal(ceilLog2(8), 8, "ceilLog2(8)"); 31 equal(nextPow2(8), 8, "nextPow2(8)");
32 equal(ceilLog2(9), 16, "ceilLog2(9)"); 32 equal(nextPow2(9), 16, "nextPow2(9)");
33 equal(ceilLog2(13), 16, "ceilLog2(16)"); 33 equal(nextPow2(13), 16, "nextPow2(13)");
René Jeschke 2014/04/21 17:24:12 I think this should read "ceilLog2(13)" instead of
34 equal(ceilLog2(1000), 1024, "ceilLog2(1000)"); 34 equal(nextPow2(1000), 1024, "nextPow2(1000)");
35 equal(ceilLog2(0x5123), 0x8000, "ceilLog2(0x5123)"); 35 equal(nextPow2(0x5123), 0x8000, "nextPow2(0x5123)");
36 equal(ceilLog2(0x31234567), 0x40000000, "ceilLog2(0x31234567)"); 36 equal(nextPow2(0x31234567), 0x40000000, "nextPow2(0x31234567)");
37 37
38 equal(log2(1), 0, "log2(1)"); 38 equal(ilog2(-1), 0, "ilog2(-1)");
39 equal(log2(2), 1, "log2(2)"); 39 equal(ilog2(1), 0, "ilog2(1)");
40 equal(log2(3), 1, "log2(3)"); 40 equal(ilog2(2), 1, "ilog2(2)");
41 equal(log2(7), 2, "log2(7)"); 41 equal(ilog2(3), 1, "ilog2(3)");
42 equal(log2(8), 3, "log2(8)"); 42 equal(ilog2(7), 2, "ilog2(7)");
43 equal(log2(9), 3, "log2(9)"); 43 equal(ilog2(8), 3, "ilog2(8)");
44 equal(log2(13), 3, "log2(16)"); 44 equal(ilog2(9), 3, "ilog2(9)");
René Jeschke 2014/04/21 17:24:12 I think this should read "log2(13)" instead of "lo
45 equal(log2(1000), 9, "log2(1000)"); 45 equal(ilog2(13), 3, "ilog2(13)");
46 equal(log2(0x5123), 14, "log2(0x5123)"); 46 equal(ilog2(1000), 9, "ilog2(1000)");
47 equal(log2(0x31234567), 29, "log2(0x31234567)"); 47 equal(ilog2(0x5123), 14, "ilog2(0x5123)");
48 equal(ilog2(0x31234567), 29, "ilog2(0x31234567)");
48 }); 49 });
49 50
50 test("Object creation and property access", function() 51 test("Object creation and property access", function()
51 { 52 {
52 // Create a type and check its properties 53 // Create a type and check its properties
53 let {ObjectType, uint8, float32} = require("typedObjects"); 54 let {ObjectType, uint8, float32} = require("typedObjects");
54 let type = new ObjectType({ 55 let type = new ObjectType({
55 foo: uint8, 56 foo: uint8,
56 bar: float32, 57 bar: float32,
57 mtd: function() { 58 mtd: function() {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 158
158 let obj3 = type2(); 159 let obj3 = type2();
159 obj3.bar = obj1; 160 obj3.bar = obj1;
160 ok(obj3.bar, "Object reference set on new object"); 161 ok(obj3.bar, "Object reference set on new object");
161 equal(obj3.bar.typeId, obj1.typeId); 162 equal(obj3.bar.typeId, obj1.typeId);
162 equal(obj3.bar.bufferIndex, obj1.bufferIndex); 163 equal(obj3.bar.bufferIndex, obj1.bufferIndex);
163 equal(obj3.bar.byteOffset, obj1.byteOffset); 164 equal(obj3.bar.byteOffset, obj1.byteOffset);
164 ok(!obj2.bar); 165 ok(!obj2.bar);
165 }); 166 });
166 })(); 167 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld