Index: test/codegen/expect/lib/convert/chunked_conversion_utf88_test.js |
diff --git a/test/codegen/expect/lib/convert/chunked_conversion_utf88_test.js b/test/codegen/expect/lib/convert/chunked_conversion_utf88_test.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a98de527de095507783d813506d2b56883c4cd12 |
--- /dev/null |
+++ b/test/codegen/expect/lib/convert/chunked_conversion_utf88_test.js |
@@ -0,0 +1,244 @@ |
+dart_library.library('lib/convert/chunked_conversion_utf88_test', null, /* Imports */[ |
+ 'dart_sdk', |
+ 'expect' |
+], function load__chunked_conversion_utf88_test(exports, dart_sdk, expect) { |
+ 'use strict'; |
+ const core = dart_sdk.core; |
+ const convert = dart_sdk.convert; |
+ const _interceptors = dart_sdk._interceptors; |
+ const dart = dart_sdk.dart; |
+ const dartx = dart_sdk.dartx; |
+ const expect$ = expect.expect; |
+ const chunked_conversion_utf88_test = Object.create(null); |
+ let ListOfint = () => (ListOfint = dart.constFn(core.List$(core.int)))(); |
+ let SinkOfListOfint = () => (SinkOfListOfint = dart.constFn(core.Sink$(ListOfint())))(); |
+ let JSArrayOfint = () => (JSArrayOfint = dart.constFn(_interceptors.JSArray$(core.int)))(); |
+ let IterableOfint = () => (IterableOfint = dart.constFn(core.Iterable$(core.int)))(); |
+ let JSArrayOfObject = () => (JSArrayOfObject = dart.constFn(_interceptors.JSArray$(core.Object)))(); |
+ let ListOfintToListOfint = () => (ListOfintToListOfint = dart.constFn(dart.definiteFunctionType(ListOfint(), [ListOfint()])))(); |
+ let StringToListOfint = () => (StringToListOfint = dart.constFn(dart.definiteFunctionType(ListOfint(), [core.String])))(); |
+ let intTovoid = () => (intTovoid = dart.constFn(dart.definiteFunctionType(dart.void, [core.int])))(); |
+ let dynamicToint = () => (dynamicToint = dart.constFn(dart.definiteFunctionType(core.int, [dart.dynamic])))(); |
+ let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [dart.dynamic])))(); |
+ let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [])))(); |
+ chunked_conversion_utf88_test.encode = function(str) { |
+ let bytes = null; |
+ let byteSink = convert.ByteConversionSink.withCallback(dart.fn(result => bytes = result, ListOfintToListOfint())); |
+ let stringConversionSink = new convert.Utf8Encoder().startChunkedConversion(SinkOfListOfint()._check(byteSink)); |
+ stringConversionSink.add(str); |
+ stringConversionSink.close(); |
+ return bytes; |
+ }; |
+ dart.fn(chunked_conversion_utf88_test.encode, StringToListOfint()); |
+ chunked_conversion_utf88_test.encode2 = function(str) { |
+ let bytes = null; |
+ let byteSink = convert.ByteConversionSink.withCallback(dart.fn(result => bytes = result, ListOfintToListOfint())); |
+ let stringConversionSink = new convert.Utf8Encoder().startChunkedConversion(SinkOfListOfint()._check(byteSink)); |
+ let stringSink = stringConversionSink.asStringSink(); |
+ stringSink.write(str); |
+ stringSink.close(); |
+ return bytes; |
+ }; |
+ dart.fn(chunked_conversion_utf88_test.encode2, StringToListOfint()); |
+ chunked_conversion_utf88_test.encode3 = function(str) { |
+ let bytes = null; |
+ let byteSink = convert.ByteConversionSink.withCallback(dart.fn(result => bytes = result, ListOfintToListOfint())); |
+ let stringConversionSink = new convert.Utf8Encoder().startChunkedConversion(SinkOfListOfint()._check(byteSink)); |
+ let stringSink = stringConversionSink.asStringSink(); |
+ str[dartx.codeUnits][dartx.forEach](dart.bind(stringSink, 'writeCharCode')); |
+ stringSink.close(); |
+ return bytes; |
+ }; |
+ dart.fn(chunked_conversion_utf88_test.encode3, StringToListOfint()); |
+ chunked_conversion_utf88_test.encode4 = function(str) { |
+ let bytes = null; |
+ let byteSink = convert.ByteConversionSink.withCallback(dart.fn(result => bytes = result, ListOfintToListOfint())); |
+ let stringConversionSink = new convert.Utf8Encoder().startChunkedConversion(SinkOfListOfint()._check(byteSink)); |
+ let stringSink = stringConversionSink.asStringSink(); |
+ str[dartx.runes].forEach(dart.bind(stringSink, 'writeCharCode')); |
+ stringSink.close(); |
+ return bytes; |
+ }; |
+ dart.fn(chunked_conversion_utf88_test.encode4, StringToListOfint()); |
+ chunked_conversion_utf88_test.encode5 = function(str) { |
+ let bytes = null; |
+ let byteSink = convert.ByteConversionSink.withCallback(dart.fn(result => bytes = result, ListOfintToListOfint())); |
+ let stringConversionSink = new convert.Utf8Encoder().startChunkedConversion(SinkOfListOfint()._check(byteSink)); |
+ let inputByteSink = stringConversionSink.asUtf8Sink(false); |
+ let tmpBytes = convert.UTF8.encode(str); |
+ inputByteSink.add(tmpBytes); |
+ inputByteSink.close(); |
+ return bytes; |
+ }; |
+ dart.fn(chunked_conversion_utf88_test.encode5, StringToListOfint()); |
+ chunked_conversion_utf88_test.encode6 = function(str) { |
+ let bytes = null; |
+ let byteSink = convert.ByteConversionSink.withCallback(dart.fn(result => bytes = result, ListOfintToListOfint())); |
+ let stringConversionSink = new convert.Utf8Encoder().startChunkedConversion(SinkOfListOfint()._check(byteSink)); |
+ let inputByteSink = stringConversionSink.asUtf8Sink(false); |
+ let tmpBytes = convert.UTF8.encode(str); |
+ tmpBytes[dartx.forEach](dart.fn(b => inputByteSink.addSlice(JSArrayOfint().of([0, b, 1]), 1, 2, false), intTovoid())); |
+ inputByteSink.close(); |
+ return bytes; |
+ }; |
+ dart.fn(chunked_conversion_utf88_test.encode6, StringToListOfint()); |
+ chunked_conversion_utf88_test.encode7 = function(str) { |
+ let bytes = null; |
+ let byteSink = convert.ByteConversionSink.withCallback(dart.fn(result => bytes = result, ListOfintToListOfint())); |
+ let stringConversionSink = new convert.Utf8Encoder().startChunkedConversion(SinkOfListOfint()._check(byteSink)); |
+ stringConversionSink.addSlice("1" + dart.notNull(str) + "2", 1, dart.notNull(str[dartx.length]) + 1, false); |
+ stringConversionSink.close(); |
+ return bytes; |
+ }; |
+ dart.fn(chunked_conversion_utf88_test.encode7, StringToListOfint()); |
+ chunked_conversion_utf88_test._nextPowerOf2 = function(v) { |
+ dart.assert(dart.dsend(v, '>', 0)); |
+ v = dart.dsend(v, '-', 1); |
+ v = dart.dsend(v, '|', dart.dsend(v, '>>', 1)); |
+ v = dart.dsend(v, '|', dart.dsend(v, '>>', 2)); |
+ v = dart.dsend(v, '|', dart.dsend(v, '>>', 4)); |
+ v = dart.dsend(v, '|', dart.dsend(v, '>>', 8)); |
+ v = dart.dsend(v, '|', dart.dsend(v, '>>', 16)); |
+ v = dart.dsend(v, '+', 1); |
+ return core.int._check(v); |
+ }; |
+ dart.fn(chunked_conversion_utf88_test._nextPowerOf2, dynamicToint()); |
+ chunked_conversion_utf88_test.runTest = function(test) { |
+ let bytes = ListOfint()._check(dart.dindex(test, 0)); |
+ let string = core.String._check(dart.dindex(test, 1)); |
+ expect$.Expect.listEquals(bytes, chunked_conversion_utf88_test.encode(string)); |
+ expect$.Expect.listEquals(bytes, chunked_conversion_utf88_test.encode2(string)); |
+ expect$.Expect.listEquals(bytes, chunked_conversion_utf88_test.encode3(string)); |
+ expect$.Expect.listEquals(bytes, chunked_conversion_utf88_test.encode4(string)); |
+ expect$.Expect.listEquals(bytes, chunked_conversion_utf88_test.encode5(string)); |
+ expect$.Expect.listEquals(bytes, chunked_conversion_utf88_test.encode6(string)); |
+ expect$.Expect.listEquals(bytes, chunked_conversion_utf88_test.encode7(string)); |
+ }; |
+ dart.fn(chunked_conversion_utf88_test.runTest, dynamicTodynamic()); |
+ let const$; |
+ let const$0; |
+ let const$1; |
+ chunked_conversion_utf88_test.main = function() { |
+ let LEADING_SURROGATE = 55297; |
+ let TRAILING_SURROGATE = 56338; |
+ let UTF8_ENCODING = const$ || (const$ = dart.constList([240, 144, 144, 146], core.int)); |
+ let UTF8_LEADING = const$0 || (const$0 = dart.constList([237, 160, 129], core.int)); |
+ let UTF8_TRAILING = const$1 || (const$1 = dart.constList([237, 176, 146], core.int)); |
+ let CHAR_A = 97; |
+ let tests = []; |
+ let codeUnits = JSArrayOfint().of([]); |
+ for (let i = 0; i < 2049; i++) { |
+ codeUnits[dartx.length] = i + 1; |
+ codeUnits[dartx.set](i, CHAR_A); |
+ if (i > 20 && dart.notNull(chunked_conversion_utf88_test._nextPowerOf2(i - 2)) - i > 10) continue; |
+ codeUnits[dartx.set](i, LEADING_SURROGATE); |
+ let str = core.String.fromCharCodes(IterableOfint()._check(codeUnits)); |
+ let bytes = core.List.filled(i + 3, CHAR_A); |
+ bytes[dartx.set](i, UTF8_LEADING[dartx.get](0)); |
+ bytes[dartx.set](i + 1, UTF8_LEADING[dartx.get](1)); |
+ bytes[dartx.set](i + 2, UTF8_LEADING[dartx.get](2)); |
+ chunked_conversion_utf88_test.runTest(JSArrayOfObject().of([bytes, str])); |
+ codeUnits[dartx.set](i, TRAILING_SURROGATE); |
+ str = core.String.fromCharCodes(IterableOfint()._check(codeUnits)); |
+ bytes = core.List.filled(i + 3, CHAR_A); |
+ bytes[dartx.set](i, UTF8_TRAILING[dartx.get](0)); |
+ bytes[dartx.set](i + 1, UTF8_TRAILING[dartx.get](1)); |
+ bytes[dartx.set](i + 2, UTF8_TRAILING[dartx.get](2)); |
+ chunked_conversion_utf88_test.runTest(JSArrayOfObject().of([bytes, str])); |
+ codeUnits[dartx.length] = i + 2; |
+ codeUnits[dartx.set](i, LEADING_SURROGATE); |
+ codeUnits[dartx.set](i + 1, TRAILING_SURROGATE); |
+ str = core.String.fromCharCodes(IterableOfint()._check(codeUnits)); |
+ bytes = core.List.filled(i + 4, CHAR_A); |
+ bytes[dartx.set](i, UTF8_ENCODING[dartx.get](0)); |
+ bytes[dartx.set](i + 1, UTF8_ENCODING[dartx.get](1)); |
+ bytes[dartx.set](i + 2, UTF8_ENCODING[dartx.get](2)); |
+ bytes[dartx.set](i + 3, UTF8_ENCODING[dartx.get](3)); |
+ chunked_conversion_utf88_test.runTest(JSArrayOfObject().of([bytes, str])); |
+ codeUnits[dartx.set](i, TRAILING_SURROGATE); |
+ codeUnits[dartx.set](i + 1, TRAILING_SURROGATE); |
+ str = core.String.fromCharCodes(IterableOfint()._check(codeUnits)); |
+ bytes = core.List.filled(i + 6, CHAR_A); |
+ bytes[dartx.set](i, UTF8_TRAILING[dartx.get](0)); |
+ bytes[dartx.set](i + 1, UTF8_TRAILING[dartx.get](1)); |
+ bytes[dartx.set](i + 2, UTF8_TRAILING[dartx.get](2)); |
+ bytes[dartx.set](i + 3, UTF8_TRAILING[dartx.get](0)); |
+ bytes[dartx.set](i + 4, UTF8_TRAILING[dartx.get](1)); |
+ bytes[dartx.set](i + 5, UTF8_TRAILING[dartx.get](2)); |
+ chunked_conversion_utf88_test.runTest(JSArrayOfObject().of([bytes, str])); |
+ codeUnits[dartx.set](i, LEADING_SURROGATE); |
+ codeUnits[dartx.set](i + 1, LEADING_SURROGATE); |
+ str = core.String.fromCharCodes(IterableOfint()._check(codeUnits)); |
+ bytes = core.List.filled(i + 6, CHAR_A); |
+ bytes[dartx.set](i, UTF8_LEADING[dartx.get](0)); |
+ bytes[dartx.set](i + 1, UTF8_LEADING[dartx.get](1)); |
+ bytes[dartx.set](i + 2, UTF8_LEADING[dartx.get](2)); |
+ bytes[dartx.set](i + 3, UTF8_LEADING[dartx.get](0)); |
+ bytes[dartx.set](i + 4, UTF8_LEADING[dartx.get](1)); |
+ bytes[dartx.set](i + 5, UTF8_LEADING[dartx.get](2)); |
+ chunked_conversion_utf88_test.runTest(JSArrayOfObject().of([bytes, str])); |
+ codeUnits[dartx.set](i, TRAILING_SURROGATE); |
+ codeUnits[dartx.set](i + 1, LEADING_SURROGATE); |
+ str = core.String.fromCharCodes(IterableOfint()._check(codeUnits)); |
+ bytes = core.List.filled(i + 6, CHAR_A); |
+ bytes[dartx.set](i, UTF8_TRAILING[dartx.get](0)); |
+ bytes[dartx.set](i + 1, UTF8_TRAILING[dartx.get](1)); |
+ bytes[dartx.set](i + 2, UTF8_TRAILING[dartx.get](2)); |
+ bytes[dartx.set](i + 3, UTF8_LEADING[dartx.get](0)); |
+ bytes[dartx.set](i + 4, UTF8_LEADING[dartx.get](1)); |
+ bytes[dartx.set](i + 5, UTF8_LEADING[dartx.get](2)); |
+ chunked_conversion_utf88_test.runTest(JSArrayOfObject().of([bytes, str])); |
+ codeUnits[dartx.length] = i + 3; |
+ codeUnits[dartx.set](i, LEADING_SURROGATE); |
+ codeUnits[dartx.set](i + 1, TRAILING_SURROGATE); |
+ codeUnits[dartx.set](i + 2, CHAR_A); |
+ str = core.String.fromCharCodes(IterableOfint()._check(codeUnits)); |
+ bytes = core.List.filled(i + 5, CHAR_A); |
+ bytes[dartx.set](i, UTF8_ENCODING[dartx.get](0)); |
+ bytes[dartx.set](i + 1, UTF8_ENCODING[dartx.get](1)); |
+ bytes[dartx.set](i + 2, UTF8_ENCODING[dartx.get](2)); |
+ bytes[dartx.set](i + 3, UTF8_ENCODING[dartx.get](3)); |
+ chunked_conversion_utf88_test.runTest(JSArrayOfObject().of([bytes, str])); |
+ codeUnits[dartx.set](i, TRAILING_SURROGATE); |
+ codeUnits[dartx.set](i + 1, TRAILING_SURROGATE); |
+ codeUnits[dartx.set](i + 2, CHAR_A); |
+ str = core.String.fromCharCodes(IterableOfint()._check(codeUnits)); |
+ bytes = core.List.filled(i + 7, CHAR_A); |
+ bytes[dartx.set](i, UTF8_TRAILING[dartx.get](0)); |
+ bytes[dartx.set](i + 1, UTF8_TRAILING[dartx.get](1)); |
+ bytes[dartx.set](i + 2, UTF8_TRAILING[dartx.get](2)); |
+ bytes[dartx.set](i + 3, UTF8_TRAILING[dartx.get](0)); |
+ bytes[dartx.set](i + 4, UTF8_TRAILING[dartx.get](1)); |
+ bytes[dartx.set](i + 5, UTF8_TRAILING[dartx.get](2)); |
+ chunked_conversion_utf88_test.runTest(JSArrayOfObject().of([bytes, str])); |
+ codeUnits[dartx.set](i, LEADING_SURROGATE); |
+ codeUnits[dartx.set](i + 1, LEADING_SURROGATE); |
+ codeUnits[dartx.set](i + 2, CHAR_A); |
+ str = core.String.fromCharCodes(IterableOfint()._check(codeUnits)); |
+ bytes = core.List.filled(i + 7, CHAR_A); |
+ bytes[dartx.set](i, UTF8_LEADING[dartx.get](0)); |
+ bytes[dartx.set](i + 1, UTF8_LEADING[dartx.get](1)); |
+ bytes[dartx.set](i + 2, UTF8_LEADING[dartx.get](2)); |
+ bytes[dartx.set](i + 3, UTF8_LEADING[dartx.get](0)); |
+ bytes[dartx.set](i + 4, UTF8_LEADING[dartx.get](1)); |
+ bytes[dartx.set](i + 5, UTF8_LEADING[dartx.get](2)); |
+ chunked_conversion_utf88_test.runTest(JSArrayOfObject().of([bytes, str])); |
+ codeUnits[dartx.set](i, TRAILING_SURROGATE); |
+ codeUnits[dartx.set](i + 1, LEADING_SURROGATE); |
+ codeUnits[dartx.set](i + 2, CHAR_A); |
+ str = core.String.fromCharCodes(IterableOfint()._check(codeUnits)); |
+ bytes = core.List.filled(i + 7, CHAR_A); |
+ bytes[dartx.set](i, UTF8_TRAILING[dartx.get](0)); |
+ bytes[dartx.set](i + 1, UTF8_TRAILING[dartx.get](1)); |
+ bytes[dartx.set](i + 2, UTF8_TRAILING[dartx.get](2)); |
+ bytes[dartx.set](i + 3, UTF8_LEADING[dartx.get](0)); |
+ bytes[dartx.set](i + 4, UTF8_LEADING[dartx.get](1)); |
+ bytes[dartx.set](i + 5, UTF8_LEADING[dartx.get](2)); |
+ chunked_conversion_utf88_test.runTest(JSArrayOfObject().of([bytes, str])); |
+ codeUnits[dartx.set](i, CHAR_A); |
+ } |
+ }; |
+ dart.fn(chunked_conversion_utf88_test.main, VoidTodynamic()); |
+ // Exports: |
+ exports.chunked_conversion_utf88_test = chunked_conversion_utf88_test; |
+}); |