OLD | NEW |
(Empty) | |
| 1 dart_library.library('lib/convert/chunked_conversion_utf88_test', null, /* Impor
ts */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__chunked_conversion_utf88_test(exports, dart_sdk, expect) { |
| 5 'use strict'; |
| 6 const core = dart_sdk.core; |
| 7 const convert = dart_sdk.convert; |
| 8 const _interceptors = dart_sdk._interceptors; |
| 9 const dart = dart_sdk.dart; |
| 10 const dartx = dart_sdk.dartx; |
| 11 const expect$ = expect.expect; |
| 12 const chunked_conversion_utf88_test = Object.create(null); |
| 13 let ListOfint = () => (ListOfint = dart.constFn(core.List$(core.int)))(); |
| 14 let SinkOfListOfint = () => (SinkOfListOfint = dart.constFn(core.Sink$(ListOfi
nt())))(); |
| 15 let JSArrayOfint = () => (JSArrayOfint = dart.constFn(_interceptors.JSArray$(c
ore.int)))(); |
| 16 let IterableOfint = () => (IterableOfint = dart.constFn(core.Iterable$(core.in
t)))(); |
| 17 let JSArrayOfObject = () => (JSArrayOfObject = dart.constFn(_interceptors.JSAr
ray$(core.Object)))(); |
| 18 let ListOfintToListOfint = () => (ListOfintToListOfint = dart.constFn(dart.def
initeFunctionType(ListOfint(), [ListOfint()])))(); |
| 19 let StringToListOfint = () => (StringToListOfint = dart.constFn(dart.definiteF
unctionType(ListOfint(), [core.String])))(); |
| 20 let intTovoid = () => (intTovoid = dart.constFn(dart.definiteFunctionType(dart
.void, [core.int])))(); |
| 21 let dynamicToint = () => (dynamicToint = dart.constFn(dart.definiteFunctionTyp
e(core.int, [dart.dynamic])))(); |
| 22 let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFun
ctionType(dart.dynamic, [dart.dynamic])))(); |
| 23 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
| 24 chunked_conversion_utf88_test.encode = function(str) { |
| 25 let bytes = null; |
| 26 let byteSink = convert.ByteConversionSink.withCallback(dart.fn(result => byt
es = result, ListOfintToListOfint())); |
| 27 let stringConversionSink = new convert.Utf8Encoder().startChunkedConversion(
SinkOfListOfint()._check(byteSink)); |
| 28 stringConversionSink.add(str); |
| 29 stringConversionSink.close(); |
| 30 return bytes; |
| 31 }; |
| 32 dart.fn(chunked_conversion_utf88_test.encode, StringToListOfint()); |
| 33 chunked_conversion_utf88_test.encode2 = function(str) { |
| 34 let bytes = null; |
| 35 let byteSink = convert.ByteConversionSink.withCallback(dart.fn(result => byt
es = result, ListOfintToListOfint())); |
| 36 let stringConversionSink = new convert.Utf8Encoder().startChunkedConversion(
SinkOfListOfint()._check(byteSink)); |
| 37 let stringSink = stringConversionSink.asStringSink(); |
| 38 stringSink.write(str); |
| 39 stringSink.close(); |
| 40 return bytes; |
| 41 }; |
| 42 dart.fn(chunked_conversion_utf88_test.encode2, StringToListOfint()); |
| 43 chunked_conversion_utf88_test.encode3 = function(str) { |
| 44 let bytes = null; |
| 45 let byteSink = convert.ByteConversionSink.withCallback(dart.fn(result => byt
es = result, ListOfintToListOfint())); |
| 46 let stringConversionSink = new convert.Utf8Encoder().startChunkedConversion(
SinkOfListOfint()._check(byteSink)); |
| 47 let stringSink = stringConversionSink.asStringSink(); |
| 48 str[dartx.codeUnits][dartx.forEach](dart.bind(stringSink, 'writeCharCode')); |
| 49 stringSink.close(); |
| 50 return bytes; |
| 51 }; |
| 52 dart.fn(chunked_conversion_utf88_test.encode3, StringToListOfint()); |
| 53 chunked_conversion_utf88_test.encode4 = function(str) { |
| 54 let bytes = null; |
| 55 let byteSink = convert.ByteConversionSink.withCallback(dart.fn(result => byt
es = result, ListOfintToListOfint())); |
| 56 let stringConversionSink = new convert.Utf8Encoder().startChunkedConversion(
SinkOfListOfint()._check(byteSink)); |
| 57 let stringSink = stringConversionSink.asStringSink(); |
| 58 str[dartx.runes].forEach(dart.bind(stringSink, 'writeCharCode')); |
| 59 stringSink.close(); |
| 60 return bytes; |
| 61 }; |
| 62 dart.fn(chunked_conversion_utf88_test.encode4, StringToListOfint()); |
| 63 chunked_conversion_utf88_test.encode5 = function(str) { |
| 64 let bytes = null; |
| 65 let byteSink = convert.ByteConversionSink.withCallback(dart.fn(result => byt
es = result, ListOfintToListOfint())); |
| 66 let stringConversionSink = new convert.Utf8Encoder().startChunkedConversion(
SinkOfListOfint()._check(byteSink)); |
| 67 let inputByteSink = stringConversionSink.asUtf8Sink(false); |
| 68 let tmpBytes = convert.UTF8.encode(str); |
| 69 inputByteSink.add(tmpBytes); |
| 70 inputByteSink.close(); |
| 71 return bytes; |
| 72 }; |
| 73 dart.fn(chunked_conversion_utf88_test.encode5, StringToListOfint()); |
| 74 chunked_conversion_utf88_test.encode6 = function(str) { |
| 75 let bytes = null; |
| 76 let byteSink = convert.ByteConversionSink.withCallback(dart.fn(result => byt
es = result, ListOfintToListOfint())); |
| 77 let stringConversionSink = new convert.Utf8Encoder().startChunkedConversion(
SinkOfListOfint()._check(byteSink)); |
| 78 let inputByteSink = stringConversionSink.asUtf8Sink(false); |
| 79 let tmpBytes = convert.UTF8.encode(str); |
| 80 tmpBytes[dartx.forEach](dart.fn(b => inputByteSink.addSlice(JSArrayOfint().o
f([0, b, 1]), 1, 2, false), intTovoid())); |
| 81 inputByteSink.close(); |
| 82 return bytes; |
| 83 }; |
| 84 dart.fn(chunked_conversion_utf88_test.encode6, StringToListOfint()); |
| 85 chunked_conversion_utf88_test.encode7 = function(str) { |
| 86 let bytes = null; |
| 87 let byteSink = convert.ByteConversionSink.withCallback(dart.fn(result => byt
es = result, ListOfintToListOfint())); |
| 88 let stringConversionSink = new convert.Utf8Encoder().startChunkedConversion(
SinkOfListOfint()._check(byteSink)); |
| 89 stringConversionSink.addSlice("1" + dart.notNull(str) + "2", 1, dart.notNull
(str[dartx.length]) + 1, false); |
| 90 stringConversionSink.close(); |
| 91 return bytes; |
| 92 }; |
| 93 dart.fn(chunked_conversion_utf88_test.encode7, StringToListOfint()); |
| 94 chunked_conversion_utf88_test._nextPowerOf2 = function(v) { |
| 95 dart.assert(dart.dsend(v, '>', 0)); |
| 96 v = dart.dsend(v, '-', 1); |
| 97 v = dart.dsend(v, '|', dart.dsend(v, '>>', 1)); |
| 98 v = dart.dsend(v, '|', dart.dsend(v, '>>', 2)); |
| 99 v = dart.dsend(v, '|', dart.dsend(v, '>>', 4)); |
| 100 v = dart.dsend(v, '|', dart.dsend(v, '>>', 8)); |
| 101 v = dart.dsend(v, '|', dart.dsend(v, '>>', 16)); |
| 102 v = dart.dsend(v, '+', 1); |
| 103 return core.int._check(v); |
| 104 }; |
| 105 dart.fn(chunked_conversion_utf88_test._nextPowerOf2, dynamicToint()); |
| 106 chunked_conversion_utf88_test.runTest = function(test) { |
| 107 let bytes = ListOfint()._check(dart.dindex(test, 0)); |
| 108 let string = core.String._check(dart.dindex(test, 1)); |
| 109 expect$.Expect.listEquals(bytes, chunked_conversion_utf88_test.encode(string
)); |
| 110 expect$.Expect.listEquals(bytes, chunked_conversion_utf88_test.encode2(strin
g)); |
| 111 expect$.Expect.listEquals(bytes, chunked_conversion_utf88_test.encode3(strin
g)); |
| 112 expect$.Expect.listEquals(bytes, chunked_conversion_utf88_test.encode4(strin
g)); |
| 113 expect$.Expect.listEquals(bytes, chunked_conversion_utf88_test.encode5(strin
g)); |
| 114 expect$.Expect.listEquals(bytes, chunked_conversion_utf88_test.encode6(strin
g)); |
| 115 expect$.Expect.listEquals(bytes, chunked_conversion_utf88_test.encode7(strin
g)); |
| 116 }; |
| 117 dart.fn(chunked_conversion_utf88_test.runTest, dynamicTodynamic()); |
| 118 let const$; |
| 119 let const$0; |
| 120 let const$1; |
| 121 chunked_conversion_utf88_test.main = function() { |
| 122 let LEADING_SURROGATE = 55297; |
| 123 let TRAILING_SURROGATE = 56338; |
| 124 let UTF8_ENCODING = const$ || (const$ = dart.constList([240, 144, 144, 146],
core.int)); |
| 125 let UTF8_LEADING = const$0 || (const$0 = dart.constList([237, 160, 129], cor
e.int)); |
| 126 let UTF8_TRAILING = const$1 || (const$1 = dart.constList([237, 176, 146], co
re.int)); |
| 127 let CHAR_A = 97; |
| 128 let tests = []; |
| 129 let codeUnits = JSArrayOfint().of([]); |
| 130 for (let i = 0; i < 2049; i++) { |
| 131 codeUnits[dartx.length] = i + 1; |
| 132 codeUnits[dartx.set](i, CHAR_A); |
| 133 if (i > 20 && dart.notNull(chunked_conversion_utf88_test._nextPowerOf2(i -
2)) - i > 10) continue; |
| 134 codeUnits[dartx.set](i, LEADING_SURROGATE); |
| 135 let str = core.String.fromCharCodes(IterableOfint()._check(codeUnits)); |
| 136 let bytes = core.List.filled(i + 3, CHAR_A); |
| 137 bytes[dartx.set](i, UTF8_LEADING[dartx.get](0)); |
| 138 bytes[dartx.set](i + 1, UTF8_LEADING[dartx.get](1)); |
| 139 bytes[dartx.set](i + 2, UTF8_LEADING[dartx.get](2)); |
| 140 chunked_conversion_utf88_test.runTest(JSArrayOfObject().of([bytes, str])); |
| 141 codeUnits[dartx.set](i, TRAILING_SURROGATE); |
| 142 str = core.String.fromCharCodes(IterableOfint()._check(codeUnits)); |
| 143 bytes = core.List.filled(i + 3, CHAR_A); |
| 144 bytes[dartx.set](i, UTF8_TRAILING[dartx.get](0)); |
| 145 bytes[dartx.set](i + 1, UTF8_TRAILING[dartx.get](1)); |
| 146 bytes[dartx.set](i + 2, UTF8_TRAILING[dartx.get](2)); |
| 147 chunked_conversion_utf88_test.runTest(JSArrayOfObject().of([bytes, str])); |
| 148 codeUnits[dartx.length] = i + 2; |
| 149 codeUnits[dartx.set](i, LEADING_SURROGATE); |
| 150 codeUnits[dartx.set](i + 1, TRAILING_SURROGATE); |
| 151 str = core.String.fromCharCodes(IterableOfint()._check(codeUnits)); |
| 152 bytes = core.List.filled(i + 4, CHAR_A); |
| 153 bytes[dartx.set](i, UTF8_ENCODING[dartx.get](0)); |
| 154 bytes[dartx.set](i + 1, UTF8_ENCODING[dartx.get](1)); |
| 155 bytes[dartx.set](i + 2, UTF8_ENCODING[dartx.get](2)); |
| 156 bytes[dartx.set](i + 3, UTF8_ENCODING[dartx.get](3)); |
| 157 chunked_conversion_utf88_test.runTest(JSArrayOfObject().of([bytes, str])); |
| 158 codeUnits[dartx.set](i, TRAILING_SURROGATE); |
| 159 codeUnits[dartx.set](i + 1, TRAILING_SURROGATE); |
| 160 str = core.String.fromCharCodes(IterableOfint()._check(codeUnits)); |
| 161 bytes = core.List.filled(i + 6, CHAR_A); |
| 162 bytes[dartx.set](i, UTF8_TRAILING[dartx.get](0)); |
| 163 bytes[dartx.set](i + 1, UTF8_TRAILING[dartx.get](1)); |
| 164 bytes[dartx.set](i + 2, UTF8_TRAILING[dartx.get](2)); |
| 165 bytes[dartx.set](i + 3, UTF8_TRAILING[dartx.get](0)); |
| 166 bytes[dartx.set](i + 4, UTF8_TRAILING[dartx.get](1)); |
| 167 bytes[dartx.set](i + 5, UTF8_TRAILING[dartx.get](2)); |
| 168 chunked_conversion_utf88_test.runTest(JSArrayOfObject().of([bytes, str])); |
| 169 codeUnits[dartx.set](i, LEADING_SURROGATE); |
| 170 codeUnits[dartx.set](i + 1, LEADING_SURROGATE); |
| 171 str = core.String.fromCharCodes(IterableOfint()._check(codeUnits)); |
| 172 bytes = core.List.filled(i + 6, CHAR_A); |
| 173 bytes[dartx.set](i, UTF8_LEADING[dartx.get](0)); |
| 174 bytes[dartx.set](i + 1, UTF8_LEADING[dartx.get](1)); |
| 175 bytes[dartx.set](i + 2, UTF8_LEADING[dartx.get](2)); |
| 176 bytes[dartx.set](i + 3, UTF8_LEADING[dartx.get](0)); |
| 177 bytes[dartx.set](i + 4, UTF8_LEADING[dartx.get](1)); |
| 178 bytes[dartx.set](i + 5, UTF8_LEADING[dartx.get](2)); |
| 179 chunked_conversion_utf88_test.runTest(JSArrayOfObject().of([bytes, str])); |
| 180 codeUnits[dartx.set](i, TRAILING_SURROGATE); |
| 181 codeUnits[dartx.set](i + 1, LEADING_SURROGATE); |
| 182 str = core.String.fromCharCodes(IterableOfint()._check(codeUnits)); |
| 183 bytes = core.List.filled(i + 6, CHAR_A); |
| 184 bytes[dartx.set](i, UTF8_TRAILING[dartx.get](0)); |
| 185 bytes[dartx.set](i + 1, UTF8_TRAILING[dartx.get](1)); |
| 186 bytes[dartx.set](i + 2, UTF8_TRAILING[dartx.get](2)); |
| 187 bytes[dartx.set](i + 3, UTF8_LEADING[dartx.get](0)); |
| 188 bytes[dartx.set](i + 4, UTF8_LEADING[dartx.get](1)); |
| 189 bytes[dartx.set](i + 5, UTF8_LEADING[dartx.get](2)); |
| 190 chunked_conversion_utf88_test.runTest(JSArrayOfObject().of([bytes, str])); |
| 191 codeUnits[dartx.length] = i + 3; |
| 192 codeUnits[dartx.set](i, LEADING_SURROGATE); |
| 193 codeUnits[dartx.set](i + 1, TRAILING_SURROGATE); |
| 194 codeUnits[dartx.set](i + 2, CHAR_A); |
| 195 str = core.String.fromCharCodes(IterableOfint()._check(codeUnits)); |
| 196 bytes = core.List.filled(i + 5, CHAR_A); |
| 197 bytes[dartx.set](i, UTF8_ENCODING[dartx.get](0)); |
| 198 bytes[dartx.set](i + 1, UTF8_ENCODING[dartx.get](1)); |
| 199 bytes[dartx.set](i + 2, UTF8_ENCODING[dartx.get](2)); |
| 200 bytes[dartx.set](i + 3, UTF8_ENCODING[dartx.get](3)); |
| 201 chunked_conversion_utf88_test.runTest(JSArrayOfObject().of([bytes, str])); |
| 202 codeUnits[dartx.set](i, TRAILING_SURROGATE); |
| 203 codeUnits[dartx.set](i + 1, TRAILING_SURROGATE); |
| 204 codeUnits[dartx.set](i + 2, CHAR_A); |
| 205 str = core.String.fromCharCodes(IterableOfint()._check(codeUnits)); |
| 206 bytes = core.List.filled(i + 7, CHAR_A); |
| 207 bytes[dartx.set](i, UTF8_TRAILING[dartx.get](0)); |
| 208 bytes[dartx.set](i + 1, UTF8_TRAILING[dartx.get](1)); |
| 209 bytes[dartx.set](i + 2, UTF8_TRAILING[dartx.get](2)); |
| 210 bytes[dartx.set](i + 3, UTF8_TRAILING[dartx.get](0)); |
| 211 bytes[dartx.set](i + 4, UTF8_TRAILING[dartx.get](1)); |
| 212 bytes[dartx.set](i + 5, UTF8_TRAILING[dartx.get](2)); |
| 213 chunked_conversion_utf88_test.runTest(JSArrayOfObject().of([bytes, str])); |
| 214 codeUnits[dartx.set](i, LEADING_SURROGATE); |
| 215 codeUnits[dartx.set](i + 1, LEADING_SURROGATE); |
| 216 codeUnits[dartx.set](i + 2, CHAR_A); |
| 217 str = core.String.fromCharCodes(IterableOfint()._check(codeUnits)); |
| 218 bytes = core.List.filled(i + 7, CHAR_A); |
| 219 bytes[dartx.set](i, UTF8_LEADING[dartx.get](0)); |
| 220 bytes[dartx.set](i + 1, UTF8_LEADING[dartx.get](1)); |
| 221 bytes[dartx.set](i + 2, UTF8_LEADING[dartx.get](2)); |
| 222 bytes[dartx.set](i + 3, UTF8_LEADING[dartx.get](0)); |
| 223 bytes[dartx.set](i + 4, UTF8_LEADING[dartx.get](1)); |
| 224 bytes[dartx.set](i + 5, UTF8_LEADING[dartx.get](2)); |
| 225 chunked_conversion_utf88_test.runTest(JSArrayOfObject().of([bytes, str])); |
| 226 codeUnits[dartx.set](i, TRAILING_SURROGATE); |
| 227 codeUnits[dartx.set](i + 1, LEADING_SURROGATE); |
| 228 codeUnits[dartx.set](i + 2, CHAR_A); |
| 229 str = core.String.fromCharCodes(IterableOfint()._check(codeUnits)); |
| 230 bytes = core.List.filled(i + 7, CHAR_A); |
| 231 bytes[dartx.set](i, UTF8_TRAILING[dartx.get](0)); |
| 232 bytes[dartx.set](i + 1, UTF8_TRAILING[dartx.get](1)); |
| 233 bytes[dartx.set](i + 2, UTF8_TRAILING[dartx.get](2)); |
| 234 bytes[dartx.set](i + 3, UTF8_LEADING[dartx.get](0)); |
| 235 bytes[dartx.set](i + 4, UTF8_LEADING[dartx.get](1)); |
| 236 bytes[dartx.set](i + 5, UTF8_LEADING[dartx.get](2)); |
| 237 chunked_conversion_utf88_test.runTest(JSArrayOfObject().of([bytes, str])); |
| 238 codeUnits[dartx.set](i, CHAR_A); |
| 239 } |
| 240 }; |
| 241 dart.fn(chunked_conversion_utf88_test.main, VoidTodynamic()); |
| 242 // Exports: |
| 243 exports.chunked_conversion_utf88_test = chunked_conversion_utf88_test; |
| 244 }); |
OLD | NEW |