OLD | NEW |
(Empty) | |
| 1 dart_library.library('language/optimized_string_charcodeat_test', null, /* Impor
ts */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__optimized_string_charcodeat_test(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 optimized_string_charcodeat_test = Object.create(null); |
| 11 let VoidToint = () => (VoidToint = dart.constFn(dart.definiteFunctionType(core
.int, [])))(); |
| 12 let StringAndintToint = () => (StringAndintToint = dart.constFn(dart.definiteF
unctionType(core.int, [core.String, core.int])))(); |
| 13 let intToint = () => (intToint = dart.constFn(dart.definiteFunctionType(core.i
nt, [core.int])))(); |
| 14 let StringToint = () => (StringToint = dart.constFn(dart.definiteFunctionType(
core.int, [core.String])))(); |
| 15 let dynamicToint = () => (dynamicToint = dart.constFn(dart.definiteFunctionTyp
e(core.int, [dart.dynamic])))(); |
| 16 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
| 17 optimized_string_charcodeat_test.one_byte = "hest"; |
| 18 optimized_string_charcodeat_test.two_byte = "h\u2029ns"; |
| 19 optimized_string_charcodeat_test.testOneByteCodeUnitAt = function(x, j) { |
| 20 function test() { |
| 21 return x[dartx.codeUnitAt](j); |
| 22 } |
| 23 dart.fn(test, VoidToint()); |
| 24 for (let i = 0; i < 20; i++) |
| 25 test(); |
| 26 return test(); |
| 27 }; |
| 28 dart.fn(optimized_string_charcodeat_test.testOneByteCodeUnitAt, StringAndintTo
int()); |
| 29 optimized_string_charcodeat_test.testTwoByteCodeUnitAt = function(x, j) { |
| 30 function test() { |
| 31 return x[dartx.codeUnitAt](j); |
| 32 } |
| 33 dart.fn(test, VoidToint()); |
| 34 for (let i = 0; i < 20; i++) |
| 35 test(); |
| 36 return test(); |
| 37 }; |
| 38 dart.fn(optimized_string_charcodeat_test.testTwoByteCodeUnitAt, StringAndintTo
int()); |
| 39 optimized_string_charcodeat_test.testConstantStringCodeUnitAt = function(j) { |
| 40 function test() { |
| 41 return "høns"[dartx.codeUnitAt](j); |
| 42 } |
| 43 dart.fn(test, VoidToint()); |
| 44 for (let i = 0; i < 20; i++) |
| 45 test(); |
| 46 return test(); |
| 47 }; |
| 48 dart.fn(optimized_string_charcodeat_test.testConstantStringCodeUnitAt, intToin
t()); |
| 49 optimized_string_charcodeat_test.testConstantIndexCodeUnitAt = function(x) { |
| 50 function test() { |
| 51 return x[dartx.codeUnitAt](1); |
| 52 } |
| 53 dart.fn(test, VoidToint()); |
| 54 for (let i = 0; i < 20; i++) |
| 55 test(); |
| 56 return test(); |
| 57 }; |
| 58 dart.fn(optimized_string_charcodeat_test.testConstantIndexCodeUnitAt, StringTo
int()); |
| 59 optimized_string_charcodeat_test.testOneByteCodeUnitAtInLoop = function(x) { |
| 60 let result = 0; |
| 61 for (let i = 0; i < dart.notNull(core.num._check(dart.dload(x, 'length')));
i++) { |
| 62 result = dart.notNull(result) + dart.notNull(core.int._check(dart.dsend(x,
'codeUnitAt', i))); |
| 63 } |
| 64 return result; |
| 65 }; |
| 66 dart.fn(optimized_string_charcodeat_test.testOneByteCodeUnitAtInLoop, dynamicT
oint()); |
| 67 optimized_string_charcodeat_test.testTwoByteCodeUnitAtInLoop = function(x) { |
| 68 let result = 0; |
| 69 for (let i = 0; i < dart.notNull(core.num._check(dart.dload(x, 'length')));
i++) { |
| 70 result = dart.notNull(result) + dart.notNull(core.int._check(dart.dsend(x,
'codeUnitAt', i))); |
| 71 } |
| 72 return result; |
| 73 }; |
| 74 dart.fn(optimized_string_charcodeat_test.testTwoByteCodeUnitAtInLoop, dynamicT
oint()); |
| 75 optimized_string_charcodeat_test.main = function() { |
| 76 for (let j = 0; j < 10; j++) { |
| 77 expect$.Expect.equals(101, optimized_string_charcodeat_test.testOneByteCod
eUnitAt(optimized_string_charcodeat_test.one_byte, 1)); |
| 78 expect$.Expect.equals(8233, optimized_string_charcodeat_test.testTwoByteCo
deUnitAt(optimized_string_charcodeat_test.two_byte, 1)); |
| 79 expect$.Expect.equals(248, optimized_string_charcodeat_test.testConstantSt
ringCodeUnitAt(1)); |
| 80 expect$.Expect.equals(101, optimized_string_charcodeat_test.testConstantIn
dexCodeUnitAt(optimized_string_charcodeat_test.one_byte)); |
| 81 } |
| 82 for (let j = 0; j < 20; j++) { |
| 83 expect$.Expect.equals(436, optimized_string_charcodeat_test.testOneByteCod
eUnitAtInLoop(optimized_string_charcodeat_test.one_byte)); |
| 84 expect$.Expect.equals(8562, optimized_string_charcodeat_test.testTwoByteCo
deUnitAtInLoop(optimized_string_charcodeat_test.two_byte)); |
| 85 } |
| 86 expect$.Expect.throws(dart.fn(() => optimized_string_charcodeat_test.testOne
ByteCodeUnitAtInLoop(123), VoidToint())); |
| 87 expect$.Expect.throws(dart.fn(() => optimized_string_charcodeat_test.testTwo
ByteCodeUnitAtInLoop(123), VoidToint())); |
| 88 }; |
| 89 dart.fn(optimized_string_charcodeat_test.main, VoidTodynamic()); |
| 90 // Exports: |
| 91 exports.optimized_string_charcodeat_test = optimized_string_charcodeat_test; |
| 92 }); |
OLD | NEW |