OLD | NEW |
(Empty) | |
| 1 dart_library.library('lib/convert/chunked_conversion_utf82_test', null, /* Impor
ts */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__chunked_conversion_utf82_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_utf82_test = Object.create(null); |
| 13 let SinkOfString = () => (SinkOfString = dart.constFn(core.Sink$(core.String))
)(); |
| 14 let ListOfint = () => (ListOfint = dart.constFn(core.List$(core.int)))(); |
| 15 let JSArrayOfint = () => (JSArrayOfint = dart.constFn(_interceptors.JSArray$(c
ore.int)))(); |
| 16 let JSArrayOfListOfint = () => (JSArrayOfListOfint = dart.constFn(_interceptor
s.JSArray$(ListOfint())))(); |
| 17 let JSArrayOfObject = () => (JSArrayOfObject = dart.constFn(_interceptors.JSAr
ray$(core.Object)))(); |
| 18 let ListOfObject = () => (ListOfObject = dart.constFn(core.List$(core.Object))
)(); |
| 19 let JSArrayOfListOfObject = () => (JSArrayOfListOfObject = dart.constFn(_inter
ceptors.JSArray$(ListOfObject())))(); |
| 20 let ListOfintAndintToString = () => (ListOfintAndintToString = dart.constFn(da
rt.definiteFunctionType(core.String, [ListOfint(), core.int])))(); |
| 21 let ListOfintToIterable = () => (ListOfintToIterable = dart.constFn(dart.defin
iteFunctionType(core.Iterable, [ListOfint()])))(); |
| 22 let ListOfObjectToListOfObject = () => (ListOfObjectToListOfObject = dart.cons
tFn(dart.definiteFunctionType(ListOfObject(), [ListOfObject()])))(); |
| 23 let VoidToString = () => (VoidToString = dart.constFn(dart.definiteFunctionTyp
e(core.String, [])))(); |
| 24 let dynamicTobool = () => (dynamicTobool = dart.constFn(dart.definiteFunctionT
ype(core.bool, [dart.dynamic])))(); |
| 25 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
| 26 chunked_conversion_utf82_test.decode = function(bytes, chunkSize) { |
| 27 let buffer = new core.StringBuffer(); |
| 28 let stringSink = convert.StringConversionSink.fromStringSink(buffer); |
| 29 let byteSink = new convert.Utf8Decoder().startChunkedConversion(SinkOfString
()._check(stringSink)); |
| 30 let i = 0; |
| 31 while (i < dart.notNull(bytes[dartx.length])) { |
| 32 let nextChunk = []; |
| 33 for (let j = 0; j < dart.notNull(chunkSize); j++) { |
| 34 if (i < dart.notNull(bytes[dartx.length])) { |
| 35 nextChunk[dartx.add](bytes[dartx.get](i)); |
| 36 i++; |
| 37 } |
| 38 } |
| 39 byteSink.add(ListOfint()._check(nextChunk)); |
| 40 } |
| 41 byteSink.close(); |
| 42 return buffer.toString(); |
| 43 }; |
| 44 dart.fn(chunked_conversion_utf82_test.decode, ListOfintAndintToString()); |
| 45 chunked_conversion_utf82_test.decodeAllowMalformed = function(bytes, chunkSize
) { |
| 46 let buffer = new core.StringBuffer(); |
| 47 let stringSink = convert.StringConversionSink.fromStringSink(buffer); |
| 48 let decoder = new convert.Utf8Decoder({allowMalformed: true}); |
| 49 let byteSink = decoder.startChunkedConversion(SinkOfString()._check(stringSi
nk)); |
| 50 let i = 0; |
| 51 while (i < dart.notNull(bytes[dartx.length])) { |
| 52 let nextChunk = []; |
| 53 for (let j = 0; j < dart.notNull(chunkSize); j++) { |
| 54 if (i < dart.notNull(bytes[dartx.length])) { |
| 55 nextChunk[dartx.add](bytes[dartx.get](i)); |
| 56 i++; |
| 57 } |
| 58 } |
| 59 byteSink.add(ListOfint()._check(nextChunk)); |
| 60 } |
| 61 byteSink.close(); |
| 62 return buffer.toString(); |
| 63 }; |
| 64 dart.fn(chunked_conversion_utf82_test.decodeAllowMalformed, ListOfintAndintToS
tring()); |
| 65 dart.defineLazy(chunked_conversion_utf82_test, { |
| 66 get TESTS() { |
| 67 return JSArrayOfListOfint().of([JSArrayOfint().of([195]), JSArrayOfint().o
f([226, 130]), JSArrayOfint().of([240, 164, 173]), JSArrayOfint().of([240, 130,
130, 172]), JSArrayOfint().of([192]), JSArrayOfint().of([193]), JSArrayOfint().o
f([245]), JSArrayOfint().of([246]), JSArrayOfint().of([247]), JSArrayOfint().of(
[248]), JSArrayOfint().of([249]), JSArrayOfint().of([250]), JSArrayOfint().of([2
51]), JSArrayOfint().of([252]), JSArrayOfint().of([253]), JSArrayOfint().of([254
]), JSArrayOfint().of([255]), JSArrayOfint().of([192, 128]), JSArrayOfint().of([
193, 128]), JSArrayOfint().of([244, 191, 191, 191])]); |
| 68 } |
| 69 }); |
| 70 dart.defineLazy(chunked_conversion_utf82_test, { |
| 71 get TESTS2() { |
| 72 return JSArrayOfListOfObject().of([JSArrayOfObject().of([JSArrayOfint().of
([192, 128, 97]), "Xa"]), JSArrayOfObject().of([JSArrayOfint().of([193, 128, 97]
), "Xa"]), JSArrayOfObject().of([JSArrayOfint().of([245, 128]), "XX"]), JSArrayO
fObject().of([JSArrayOfint().of([246, 128]), "XX"]), JSArrayOfObject().of([JSArr
ayOfint().of([247, 128]), "XX"]), JSArrayOfObject().of([JSArrayOfint().of([248,
128]), "XX"]), JSArrayOfObject().of([JSArrayOfint().of([249, 128]), "XX"]), JSAr
rayOfObject().of([JSArrayOfint().of([250, 128]), "XX"]), JSArrayOfObject().of([J
SArrayOfint().of([251, 128]), "XX"]), JSArrayOfObject().of([JSArrayOfint().of([2
52, 128]), "XX"]), JSArrayOfObject().of([JSArrayOfint().of([253, 128]), "XX"]),
JSArrayOfObject().of([JSArrayOfint().of([254, 128]), "XX"]), JSArrayOfObject().o
f([JSArrayOfint().of([255, 128]), "XX"]), JSArrayOfObject().of([JSArrayOfint().o
f([245, 128, 97]), "XXa"]), JSArrayOfObject().of([JSArrayOfint().of([246, 128, 9
7]), "XXa"]), JSArrayOfObject().of([JSArrayOfint().of([247, 128, 97]), "XXa"]),
JSArrayOfObject().of([JSArrayOfint().of([248, 128, 97]), "XXa"]), JSArrayOfObjec
t().of([JSArrayOfint().of([249, 128, 97]), "XXa"]), JSArrayOfObject().of([JSArra
yOfint().of([250, 128, 97]), "XXa"]), JSArrayOfObject().of([JSArrayOfint().of([2
51, 128, 97]), "XXa"]), JSArrayOfObject().of([JSArrayOfint().of([252, 128, 97]),
"XXa"]), JSArrayOfObject().of([JSArrayOfint().of([253, 128, 97]), "XXa"]), JSAr
rayOfObject().of([JSArrayOfint().of([254, 128, 97]), "XXa"]), JSArrayOfObject().
of([JSArrayOfint().of([255, 128, 97]), "XXa"]), JSArrayOfObject().of([JSArrayOfi
nt().of([245, 128, 128, 97]), "XXXa"]), JSArrayOfObject().of([JSArrayOfint().of(
[246, 128, 128, 97]), "XXXa"]), JSArrayOfObject().of([JSArrayOfint().of([247, 12
8, 128, 97]), "XXXa"]), JSArrayOfObject().of([JSArrayOfint().of([248, 128, 128,
97]), "XXXa"]), JSArrayOfObject().of([JSArrayOfint().of([249, 128, 128, 97]), "X
XXa"]), JSArrayOfObject().of([JSArrayOfint().of([250, 128, 128, 97]), "XXXa"]),
JSArrayOfObject().of([JSArrayOfint().of([251, 128, 128, 97]), "XXXa"]), JSArrayO
fObject().of([JSArrayOfint().of([252, 128, 128, 97]), "XXXa"]), JSArrayOfObject(
).of([JSArrayOfint().of([253, 128, 128, 97]), "XXXa"]), JSArrayOfObject().of([JS
ArrayOfint().of([254, 128, 128, 97]), "XXXa"]), JSArrayOfObject().of([JSArrayOfi
nt().of([255, 128, 128, 97]), "XXXa"])]); |
| 73 } |
| 74 }); |
| 75 chunked_conversion_utf82_test.main = function() { |
| 76 let allTests = chunked_conversion_utf82_test.TESTS[dartx.expand](dart.dynami
c)(dart.fn(test => JSArrayOfListOfObject().of([JSArrayOfObject().of([test, "�"])
, JSArrayOfObject().of([(() => { |
| 77 let _ = core.List.from(JSArrayOfint().of([97])); |
| 78 _[dartx.addAll](test); |
| 79 return _; |
| 80 })(), "a�"]), JSArrayOfObject().of([(() => { |
| 81 let _ = core.List.from(JSArrayOfint().of([97])); |
| 82 _[dartx.addAll](test); |
| 83 _[dartx.add](97); |
| 84 return _; |
| 85 })(), "a�a"]), JSArrayOfObject().of([(() => { |
| 86 let _ = core.List.from(test); |
| 87 _[dartx.add](97); |
| 88 return _; |
| 89 })(), "�a"]), JSArrayOfObject().of([(() => { |
| 90 let _ = core.List.from(test); |
| 91 _[dartx.addAll](test); |
| 92 return _; |
| 93 })(), "��"]), JSArrayOfObject().of([(() => { |
| 94 let _ = core.List.from(test); |
| 95 _[dartx.add](97); |
| 96 _[dartx.addAll](test); |
| 97 return _; |
| 98 })(), "�a�"]), JSArrayOfObject().of([(() => { |
| 99 let _ = core.List.from(JSArrayOfint().of([195, 165])); |
| 100 _[dartx.addAll](test); |
| 101 return _; |
| 102 })(), "å�"]), JSArrayOfObject().of([(() => { |
| 103 let _ = core.List.from(JSArrayOfint().of([195, 165])); |
| 104 _[dartx.addAll](test); |
| 105 _[dartx.addAll](JSArrayOfint().of([195, 165])); |
| 106 return _; |
| 107 })(), "å�å"]), JSArrayOfObject().of([(() => { |
| 108 let _ = core.List.from(test); |
| 109 _[dartx.addAll](JSArrayOfint().of([195, 165])); |
| 110 return _; |
| 111 })(), "�å"]), JSArrayOfObject().of([(() => { |
| 112 let _ = core.List.from(test); |
| 113 _[dartx.addAll](JSArrayOfint().of([195, 165])); |
| 114 _[dartx.addAll](test); |
| 115 return _; |
| 116 })(), "�å�"])]), ListOfintToIterable())); |
| 117 let allTests2 = chunked_conversion_utf82_test.TESTS2[dartx.map](ListOfObject
())(dart.fn(test => { |
| 118 let expected = core.String.as(test[dartx.get](1))[dartx.replaceAll]("X", "
�"); |
| 119 return JSArrayOfObject().of([test[dartx.get](0), expected]); |
| 120 }, ListOfObjectToListOfObject())); |
| 121 for (let test of (() => { |
| 122 let _ = []; |
| 123 _[dartx.addAll](allTests); |
| 124 _[dartx.addAll](allTests2); |
| 125 return _; |
| 126 })()) { |
| 127 let bytes = ListOfint()._check(dart.dindex(test, 0)); |
| 128 expect$.Expect.throws(dart.fn(() => chunked_conversion_utf82_test.decode(b
ytes, 1), VoidToString()), dart.fn(e => core.FormatException.is(e), dynamicToboo
l())); |
| 129 expect$.Expect.throws(dart.fn(() => chunked_conversion_utf82_test.decode(b
ytes, 2), VoidToString()), dart.fn(e => core.FormatException.is(e), dynamicToboo
l())); |
| 130 expect$.Expect.throws(dart.fn(() => chunked_conversion_utf82_test.decode(b
ytes, 3), VoidToString()), dart.fn(e => core.FormatException.is(e), dynamicToboo
l())); |
| 131 expect$.Expect.throws(dart.fn(() => chunked_conversion_utf82_test.decode(b
ytes, 4), VoidToString()), dart.fn(e => core.FormatException.is(e), dynamicToboo
l())); |
| 132 let expected = core.String._check(dart.dindex(test, 1)); |
| 133 expect$.Expect.equals(expected, chunked_conversion_utf82_test.decodeAllowM
alformed(bytes, 1)); |
| 134 expect$.Expect.equals(expected, chunked_conversion_utf82_test.decodeAllowM
alformed(bytes, 2)); |
| 135 expect$.Expect.equals(expected, chunked_conversion_utf82_test.decodeAllowM
alformed(bytes, 3)); |
| 136 expect$.Expect.equals(expected, chunked_conversion_utf82_test.decodeAllowM
alformed(bytes, 4)); |
| 137 } |
| 138 }; |
| 139 dart.fn(chunked_conversion_utf82_test.main, VoidTodynamic()); |
| 140 // Exports: |
| 141 exports.chunked_conversion_utf82_test = chunked_conversion_utf82_test; |
| 142 }); |
OLD | NEW |