OLD | NEW |
(Empty) | |
| 1 dart_library.library('lib/convert/utf82_test', null, /* Imports */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__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 utf82_test = Object.create(null); |
| 13 let ListOfint = () => (ListOfint = dart.constFn(core.List$(core.int)))(); |
| 14 let JSArrayOfint = () => (JSArrayOfint = dart.constFn(_interceptors.JSArray$(c
ore.int)))(); |
| 15 let JSArrayOfListOfint = () => (JSArrayOfListOfint = dart.constFn(_interceptor
s.JSArray$(ListOfint())))(); |
| 16 let JSArrayOfObject = () => (JSArrayOfObject = dart.constFn(_interceptors.JSAr
ray$(core.Object)))(); |
| 17 let ListOfObject = () => (ListOfObject = dart.constFn(core.List$(core.Object))
)(); |
| 18 let JSArrayOfListOfObject = () => (JSArrayOfListOfObject = dart.constFn(_inter
ceptors.JSArray$(ListOfObject())))(); |
| 19 let ListOfintToString = () => (ListOfintToString = dart.constFn(dart.definiteF
unctionType(core.String, [ListOfint()])))(); |
| 20 let ListOfintToIterable = () => (ListOfintToIterable = dart.constFn(dart.defin
iteFunctionType(core.Iterable, [ListOfint()])))(); |
| 21 let ListOfObjectToListOfObject = () => (ListOfObjectToListOfObject = dart.cons
tFn(dart.definiteFunctionType(ListOfObject(), [ListOfObject()])))(); |
| 22 let VoidToString = () => (VoidToString = dart.constFn(dart.definiteFunctionTyp
e(core.String, [])))(); |
| 23 let dynamicTobool = () => (dynamicTobool = dart.constFn(dart.definiteFunctionT
ype(core.bool, [dart.dynamic])))(); |
| 24 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
| 25 utf82_test.decode = function(bytes) { |
| 26 return new convert.Utf8Decoder().convert(bytes); |
| 27 }; |
| 28 dart.fn(utf82_test.decode, ListOfintToString()); |
| 29 utf82_test.decodeAllowMalformed = function(bytes) { |
| 30 return new convert.Utf8Decoder({allowMalformed: true}).convert(bytes); |
| 31 }; |
| 32 dart.fn(utf82_test.decodeAllowMalformed, ListOfintToString()); |
| 33 utf82_test.decode2 = function(bytes) { |
| 34 return convert.UTF8.decode(bytes); |
| 35 }; |
| 36 dart.fn(utf82_test.decode2, ListOfintToString()); |
| 37 utf82_test.decodeAllowMalformed2 = function(bytes) { |
| 38 return convert.UTF8.decode(bytes, {allowMalformed: true}); |
| 39 }; |
| 40 dart.fn(utf82_test.decodeAllowMalformed2, ListOfintToString()); |
| 41 utf82_test.decode3 = function(bytes) { |
| 42 return new convert.Utf8Codec().decode(bytes); |
| 43 }; |
| 44 dart.fn(utf82_test.decode3, ListOfintToString()); |
| 45 utf82_test.decodeAllowMalformed3 = function(bytes) { |
| 46 return new convert.Utf8Codec({allowMalformed: true}).decode(bytes); |
| 47 }; |
| 48 dart.fn(utf82_test.decodeAllowMalformed3, ListOfintToString()); |
| 49 utf82_test.decode4 = function(bytes) { |
| 50 return new convert.Utf8Codec().decoder.convert(bytes); |
| 51 }; |
| 52 dart.fn(utf82_test.decode4, ListOfintToString()); |
| 53 utf82_test.decodeAllowMalformed4 = function(bytes) { |
| 54 return new convert.Utf8Codec({allowMalformed: true}).decoder.convert(bytes); |
| 55 }; |
| 56 dart.fn(utf82_test.decodeAllowMalformed4, ListOfintToString()); |
| 57 dart.defineLazy(utf82_test, { |
| 58 get TESTS() { |
| 59 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]), JSArrayOfint().of([-1]), JS
ArrayOfint().of([-255]), JSArrayOfint().of([-2147483648]), JSArrayOfint().of([-1
073741824]), JSArrayOfint().of([-147573952589676412928])]); |
| 60 } |
| 61 }); |
| 62 dart.defineLazy(utf82_test, { |
| 63 get TESTS2() { |
| 64 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"])]); |
| 65 } |
| 66 }); |
| 67 utf82_test.main = function() { |
| 68 let allTests = utf82_test.TESTS[dartx.expand](dart.dynamic)(dart.fn(test =>
JSArrayOfListOfObject().of([JSArrayOfObject().of([test, "�"]), JSArrayOfObject()
.of([(() => { |
| 69 let _ = core.List.from(JSArrayOfint().of([97])); |
| 70 _[dartx.addAll](test); |
| 71 return _; |
| 72 })(), "a�"]), JSArrayOfObject().of([(() => { |
| 73 let _ = core.List.from(JSArrayOfint().of([97])); |
| 74 _[dartx.addAll](test); |
| 75 _[dartx.add](97); |
| 76 return _; |
| 77 })(), "a�a"]), JSArrayOfObject().of([(() => { |
| 78 let _ = core.List.from(test); |
| 79 _[dartx.add](97); |
| 80 return _; |
| 81 })(), "�a"]), JSArrayOfObject().of([(() => { |
| 82 let _ = core.List.from(test); |
| 83 _[dartx.addAll](test); |
| 84 return _; |
| 85 })(), "��"]), JSArrayOfObject().of([(() => { |
| 86 let _ = core.List.from(test); |
| 87 _[dartx.add](97); |
| 88 _[dartx.addAll](test); |
| 89 return _; |
| 90 })(), "�a�"]), JSArrayOfObject().of([(() => { |
| 91 let _ = core.List.from(JSArrayOfint().of([195, 165])); |
| 92 _[dartx.addAll](test); |
| 93 return _; |
| 94 })(), "å�"]), JSArrayOfObject().of([(() => { |
| 95 let _ = core.List.from(JSArrayOfint().of([195, 165])); |
| 96 _[dartx.addAll](test); |
| 97 _[dartx.addAll](JSArrayOfint().of([195, 165])); |
| 98 return _; |
| 99 })(), "å�å"]), JSArrayOfObject().of([(() => { |
| 100 let _ = core.List.from(test); |
| 101 _[dartx.addAll](JSArrayOfint().of([195, 165])); |
| 102 return _; |
| 103 })(), "�å"]), JSArrayOfObject().of([(() => { |
| 104 let _ = core.List.from(test); |
| 105 _[dartx.addAll](JSArrayOfint().of([195, 165])); |
| 106 _[dartx.addAll](test); |
| 107 return _; |
| 108 })(), "�å�"])]), ListOfintToIterable())); |
| 109 let allTests2 = utf82_test.TESTS2[dartx.map](ListOfObject())(dart.fn(test =>
{ |
| 110 let expected = core.String.as(test[dartx.get](1))[dartx.replaceAll]("X", "
�"); |
| 111 return JSArrayOfObject().of([test[dartx.get](0), expected]); |
| 112 }, ListOfObjectToListOfObject())); |
| 113 for (let test of (() => { |
| 114 let _ = []; |
| 115 _[dartx.addAll](allTests); |
| 116 _[dartx.addAll](allTests2); |
| 117 return _; |
| 118 })()) { |
| 119 let bytes = ListOfint()._check(dart.dindex(test, 0)); |
| 120 expect$.Expect.throws(dart.fn(() => utf82_test.decode(bytes), VoidToString
()), dart.fn(e => core.FormatException.is(e), dynamicTobool())); |
| 121 expect$.Expect.throws(dart.fn(() => utf82_test.decode2(bytes), VoidToStrin
g()), dart.fn(e => core.FormatException.is(e), dynamicTobool())); |
| 122 expect$.Expect.throws(dart.fn(() => utf82_test.decode3(bytes), VoidToStrin
g()), dart.fn(e => core.FormatException.is(e), dynamicTobool())); |
| 123 expect$.Expect.throws(dart.fn(() => utf82_test.decode4(bytes), VoidToStrin
g()), dart.fn(e => core.FormatException.is(e), dynamicTobool())); |
| 124 let expected = core.String._check(dart.dindex(test, 1)); |
| 125 expect$.Expect.equals(expected, utf82_test.decodeAllowMalformed(bytes)); |
| 126 expect$.Expect.equals(expected, utf82_test.decodeAllowMalformed2(bytes)); |
| 127 expect$.Expect.equals(expected, utf82_test.decodeAllowMalformed3(bytes)); |
| 128 expect$.Expect.equals(expected, utf82_test.decodeAllowMalformed4(bytes)); |
| 129 } |
| 130 }; |
| 131 dart.fn(utf82_test.main, VoidTodynamic()); |
| 132 // Exports: |
| 133 exports.utf82_test = utf82_test; |
| 134 }); |
OLD | NEW |