OLD | NEW |
(Empty) | |
| 1 dart_library.library('language/bit_operations_test_04_multi', null, /* Imports *
/[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__bit_operations_test_04_multi(exports, dart_sdk, expect) { |
| 5 'use strict'; |
| 6 const core = dart_sdk.core; |
| 7 const dart = dart_sdk.dart; |
| 8 const dartx = dart_sdk.dartx; |
| 9 const expect$ = expect.expect; |
| 10 const bit_operations_test_04_multi = Object.create(null); |
| 11 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(da
rt.void, [])))(); |
| 12 let dynamicAnddynamicTobool = () => (dynamicAnddynamicTobool = dart.constFn(da
rt.definiteFunctionType(core.bool, [dart.dynamic, dart.dynamic])))(); |
| 13 let intAndintToint = () => (intAndintToint = dart.constFn(dart.definiteFunctio
nType(core.int, [core.int, core.int])))(); |
| 14 let intAndintAndint__Tovoid = () => (intAndintAndint__Tovoid = dart.constFn(da
rt.definiteFunctionType(dart.void, [core.int, core.int, core.int, core.int])))()
; |
| 15 bit_operations_test_04_multi.main = function() { |
| 16 for (let i = 0; i < 4; i++) { |
| 17 bit_operations_test_04_multi.test(); |
| 18 } |
| 19 }; |
| 20 dart.fn(bit_operations_test_04_multi.main, VoidTovoid()); |
| 21 bit_operations_test_04_multi.test = function() { |
| 22 expect$.Expect.equals(3, 3 & 7); |
| 23 expect$.Expect.equals(7, 3 | 7); |
| 24 expect$.Expect.equals(4, 3 ^ 7); |
| 25 expect$.Expect.equals(25, 100 >> 2); |
| 26 expect$.Expect.equals(400, 100 << 2); |
| 27 expect$.Expect.equals(-25, (-100)[dartx['>>']](2)); |
| 28 expect$.Expect.equals(-101, ~100 >>> 0); |
| 29 expect$.Expect.equals(18446744073709551616, (1)[dartx['<<']](64)); |
| 30 expect$.Expect.equals(-18446744073709551616, (-1)[dartx['<<']](64)); |
| 31 expect$.Expect.equals(1073741824, 67108864 << 4); |
| 32 expect$.Expect.equals(4611686018427387904, 288230376151711744 << 4 >>> 0); |
| 33 expect$.Expect.equals(0, ~-1 >>> 0); |
| 34 expect$.Expect.equals(-1, ~0 >>> 0); |
| 35 expect$.Expect.equals(0, (1)[dartx['>>']](160)); |
| 36 expect$.Expect.equals(-1, (-1)[dartx['>>']](160)); |
| 37 expect$.Expect.equals(295147905179352825857, (295147905179352825857 & 295147
922835963379713) >>> 0); |
| 38 expect$.Expect.equals(1, 1 & 295147922835963379713); |
| 39 expect$.Expect.equals(1, 295147922835963379713 & 1); |
| 40 expect$.Expect.equals(295147922835963379713, (295147905179352825857 | 295147
922835963379713) >>> 0); |
| 41 expect$.Expect.equals(295147922835963379729, (17 | 295147922835963379713) >>
> 0); |
| 42 expect$.Expect.equals(295147922835963379729, (295147922835963379713 | 17) >>
> 0); |
| 43 expect$.Expect.equals(70836578106955247124480, (4428299441600861306881 ^ 752
62715820734970593281) >>> 0); |
| 44 expect$.Expect.equals(49, (4428299441600861306881 ^ 4428299441600861306928)
>>> 0); |
| 45 expect$.Expect.equals(4428299441600861306929, (4428299441600861306881 ^ 48)
>>> 0); |
| 46 expect$.Expect.equals(4428299441600861306929, (48 ^ 4428299441600861306881)
>>> 0); |
| 47 expect$.Expect.equals(4427218577690292387855, 70835497243044678205687 >>> 4)
; |
| 48 expect$.Expect.equals(15, (64424509440)[dartx['>>']](32)); |
| 49 expect$.Expect.equals(1030792151040, 16492674416655 >>> 4); |
| 50 expect$.Expect.equals(70835497243044678205680, 4427218577690292387855 << 4 >
>> 0); |
| 51 expect$.Expect.equals(64424509440, (15)[dartx['<<']](32)); |
| 52 bit_operations_test_04_multi.testNegativeValueShifts(); |
| 53 bit_operations_test_04_multi.testPositiveValueShifts(); |
| 54 bit_operations_test_04_multi.testNoMaskingOfShiftCount(); |
| 55 bit_operations_test_04_multi.testNegativeCountShifts(); |
| 56 for (let i = 0; i < 20; i++) { |
| 57 bit_operations_test_04_multi.testCornerCasesRightShifts(); |
| 58 bit_operations_test_04_multi.testRightShift64Bit(); |
| 59 bit_operations_test_04_multi.testLeftShift64Bit(); |
| 60 bit_operations_test_04_multi.testLeftShift64BitWithOverflow1(); |
| 61 bit_operations_test_04_multi.testLeftShift64BitWithOverflow2(); |
| 62 bit_operations_test_04_multi.testLeftShift64BitWithOverflow3(); |
| 63 } |
| 64 bit_operations_test_04_multi.testPrecedence(4, 5, 3, 1); |
| 65 bit_operations_test_04_multi.testPrecedence(3, 4, 5, 9); |
| 66 bit_operations_test_04_multi.testPrecedence(23665, 27538, 30292, 32040); |
| 67 }; |
| 68 dart.fn(bit_operations_test_04_multi.test, VoidTovoid()); |
| 69 bit_operations_test_04_multi.testCornerCasesRightShifts = function() { |
| 70 let v32 = 4278190080; |
| 71 let v64 = 18374686479671623680; |
| 72 expect$.Expect.equals(3, v32[dartx['>>']](30)); |
| 73 expect$.Expect.equals(1, v32[dartx['>>']](31)); |
| 74 expect$.Expect.equals(0, v32[dartx['>>']](32)); |
| 75 expect$.Expect.equals(3, v64[dartx['>>']](62)); |
| 76 expect$.Expect.equals(1, v64[dartx['>>']](63)); |
| 77 expect$.Expect.equals(0, v64[dartx['>>']](64)); |
| 78 }; |
| 79 dart.fn(bit_operations_test_04_multi.testCornerCasesRightShifts, VoidTovoid())
; |
| 80 bit_operations_test_04_multi.testRightShift64Bit = function() { |
| 81 let t = 8589934591; |
| 82 expect$.Expect.equals(4294967295, t[dartx['>>']](1)); |
| 83 }; |
| 84 dart.fn(bit_operations_test_04_multi.testRightShift64Bit, VoidTovoid()); |
| 85 bit_operations_test_04_multi.testLeftShift64Bit = function() { |
| 86 let t = 4294967295; |
| 87 expect$.Expect.equals(4294967295, t << 0 >>> 0); |
| 88 expect$.Expect.equals(8589934590, t << 1 >>> 0); |
| 89 expect$.Expect.equals(9223372034707292160, t << 31 >>> 0); |
| 90 expect$.Expect.equals(9223372036854775808, t + 1 << 31 >>> 0); |
| 91 }; |
| 92 dart.fn(bit_operations_test_04_multi.testLeftShift64Bit, VoidTovoid()); |
| 93 bit_operations_test_04_multi.testLeftShift64BitWithOverflow1 = function() { |
| 94 let t = 4294967295; |
| 95 }; |
| 96 dart.fn(bit_operations_test_04_multi.testLeftShift64BitWithOverflow1, VoidTovo
id()); |
| 97 bit_operations_test_04_multi.testLeftShift64BitWithOverflow2 = function() { |
| 98 let t = 4294967295; |
| 99 expect$.Expect.equals(36893488147419103232, 4 * (t + 1) << 31 >>> 0); |
| 100 }; |
| 101 dart.fn(bit_operations_test_04_multi.testLeftShift64BitWithOverflow2, VoidTovo
id()); |
| 102 bit_operations_test_04_multi.testLeftShift64BitWithOverflow3 = function() { |
| 103 let t = 4294967295; |
| 104 expect$.Expect.equals(9223372036854775808, t + 1 << 31 >>> 0); |
| 105 }; |
| 106 dart.fn(bit_operations_test_04_multi.testLeftShift64BitWithOverflow3, VoidTovo
id()); |
| 107 bit_operations_test_04_multi.testNegativeCountShifts = function() { |
| 108 function throwOnLeft(a, b) { |
| 109 try { |
| 110 let x = dart.dsend(a, '<<', b); |
| 111 return false; |
| 112 } catch (e) { |
| 113 return true; |
| 114 } |
| 115 |
| 116 } |
| 117 dart.fn(throwOnLeft, dynamicAnddynamicTobool()); |
| 118 function throwOnRight(a, b) { |
| 119 try { |
| 120 let x = dart.dsend(a, '>>', b); |
| 121 return false; |
| 122 } catch (e) { |
| 123 return true; |
| 124 } |
| 125 |
| 126 } |
| 127 dart.fn(throwOnRight, dynamicAnddynamicTobool()); |
| 128 expect$.Expect.isTrue(throwOnLeft(12, -3)); |
| 129 expect$.Expect.isTrue(throwOnRight(12, -3)); |
| 130 for (let i = 0; i < 20; i++) { |
| 131 expect$.Expect.isFalse(throwOnLeft(12, 3)); |
| 132 expect$.Expect.isFalse(throwOnRight(12, 3)); |
| 133 } |
| 134 }; |
| 135 dart.fn(bit_operations_test_04_multi.testNegativeCountShifts, VoidTovoid()); |
| 136 bit_operations_test_04_multi.testNegativeValueShifts = function() { |
| 137 for (let value = 0; value > -100; value--) { |
| 138 for (let i = 0; i < 300; i++) { |
| 139 let b = value[dartx['<<']](i)[dartx['>>']](i); |
| 140 expect$.Expect.equals(value, b); |
| 141 } |
| 142 } |
| 143 }; |
| 144 dart.fn(bit_operations_test_04_multi.testNegativeValueShifts, VoidTovoid()); |
| 145 bit_operations_test_04_multi.testPositiveValueShifts = function() { |
| 146 for (let value = 0; value < 100; value++) { |
| 147 for (let i = 0; i < 300; i++) { |
| 148 let b = value[dartx['<<']](i)[dartx['>>']](i); |
| 149 expect$.Expect.equals(value, b); |
| 150 } |
| 151 } |
| 152 }; |
| 153 dart.fn(bit_operations_test_04_multi.testPositiveValueShifts, VoidTovoid()); |
| 154 bit_operations_test_04_multi.testNoMaskingOfShiftCount = function() { |
| 155 expect$.Expect.equals(0, (0)[dartx['>>']](256)); |
| 156 expect$.Expect.equals(0, (1)[dartx['>>']](256)); |
| 157 expect$.Expect.equals(0, (2)[dartx['>>']](256)); |
| 158 expect$.Expect.equals(0, bit_operations_test_04_multi.shiftRight(0, 256)); |
| 159 expect$.Expect.equals(0, bit_operations_test_04_multi.shiftRight(1, 256)); |
| 160 expect$.Expect.equals(0, bit_operations_test_04_multi.shiftRight(2, 256)); |
| 161 for (let shift = 1; shift <= 256; shift++) { |
| 162 expect$.Expect.equals(0, bit_operations_test_04_multi.shiftRight(1, shift)
); |
| 163 expect$.Expect.equals(-1, bit_operations_test_04_multi.shiftRight(-1, shif
t)); |
| 164 expect$.Expect.equals(true, dart.notNull(bit_operations_test_04_multi.shif
tLeft(1, shift)) > dart.notNull(bit_operations_test_04_multi.shiftLeft(1, shift
- 1))); |
| 165 } |
| 166 }; |
| 167 dart.fn(bit_operations_test_04_multi.testNoMaskingOfShiftCount, VoidTovoid()); |
| 168 bit_operations_test_04_multi.shiftLeft = function(a, b) { |
| 169 return a[dartx['<<']](b); |
| 170 }; |
| 171 dart.fn(bit_operations_test_04_multi.shiftLeft, intAndintToint()); |
| 172 bit_operations_test_04_multi.shiftRight = function(a, b) { |
| 173 return a[dartx['>>']](b); |
| 174 }; |
| 175 dart.fn(bit_operations_test_04_multi.shiftRight, intAndintToint()); |
| 176 bit_operations_test_04_multi.testPrecedence = function(a, b, c, d) { |
| 177 let result = (dart.notNull(a) & dart.notNull(b) ^ dart.notNull(c) | dart.not
Null(d) & dart.notNull(b) ^ dart.notNull(c)) >>> 0; |
| 178 expect$.Expect.equals((dart.notNull(a) & dart.notNull(b) ^ dart.notNull(c) |
dart.notNull(d) & dart.notNull(b) ^ dart.notNull(c)) >>> 0, result); |
| 179 expect$.Expect.notEquals((dart.notNull(a) & (dart.notNull(b) ^ dart.notNull(
c)) | dart.notNull(d) & (dart.notNull(b) ^ dart.notNull(c))) >>> 0, result); |
| 180 expect$.Expect.notEquals((dart.notNull(a) & dart.notNull(b) ^ (dart.notNull(
c) | dart.notNull(d) & dart.notNull(b)) ^ dart.notNull(c)) >>> 0, result); |
| 181 expect$.Expect.notEquals((dart.notNull(a) & dart.notNull(b) ^ (dart.notNull(
c) | dart.notNull(d)) & dart.notNull(b) ^ dart.notNull(c)) >>> 0, result); |
| 182 expect$.Expect.notEquals((dart.notNull(a) & (dart.notNull(b) ^ (dart.notNull
(c) | dart.notNull(d))) & (dart.notNull(b) ^ dart.notNull(c))) >>> 0, result); |
| 183 expect$.Expect.notEquals((dart.notNull(a) & (dart.notNull(b) ^ dart.notNull(
c) | dart.notNull(d)) & (dart.notNull(b) ^ dart.notNull(c))) >>> 0, result); |
| 184 expect$.Expect.equals((dart.notNull(a) & dart.notNull(b)) >>> 0 < (dart.notN
ull(c) & dart.notNull(d)) >>> 0, (dart.notNull(a) & dart.notNull(b)) >>> 0 < (da
rt.notNull(c) & dart.notNull(d)) >>> 0); |
| 185 expect$.Expect.equals((dart.notNull(a) & b[dartx['<<']](c) ^ dart.notNull(d)
) >>> 0, (dart.notNull(a) & b[dartx['<<']](c) ^ dart.notNull(d)) >>> 0); |
| 186 expect$.Expect.notEquals(((dart.notNull(a) & dart.notNull(b)) >>> 0)[dartx['
<<']]((dart.notNull(c) ^ dart.notNull(d)) >>> 0), (dart.notNull(a) & b[dartx['<<
']](c) ^ dart.notNull(d)) >>> 0); |
| 187 }; |
| 188 dart.fn(bit_operations_test_04_multi.testPrecedence, intAndintAndint__Tovoid()
); |
| 189 // Exports: |
| 190 exports.bit_operations_test_04_multi = bit_operations_test_04_multi; |
| 191 }); |
OLD | NEW |