Skip to content

Commit f720939

Browse files
Add tests
1 parent d5f1e1c commit f720939

8 files changed

Lines changed: 931 additions & 0 deletions
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
toFromHexBase64.ts(1,25): error TS2339: Property 'fromBase64' does not exist on type 'Uint8ArrayConstructor'.
2+
toFromHexBase64.ts(2,25): error TS2339: Property 'fromBase64' does not exist on type 'Uint8ArrayConstructor'.
3+
toFromHexBase64.ts(3,25): error TS2339: Property 'fromHex' does not exist on type 'Uint8ArrayConstructor'.
4+
toFromHexBase64.ts(12,20): error TS2550: Property 'setFromBase64' does not exist on type 'Uint8Array<ArrayBuffer>'. Do you need to change your target library? Try changing the 'lib' compiler option to 'esnext' or later.
5+
toFromHexBase64.ts(13,20): error TS2550: Property 'setFromBase64' does not exist on type 'Uint8Array<ArrayBuffer>'. Do you need to change your target library? Try changing the 'lib' compiler option to 'esnext' or later.
6+
toFromHexBase64.ts(14,20): error TS2550: Property 'setFromBase64' does not exist on type 'Uint8Array<ArrayBuffer>'. Do you need to change your target library? Try changing the 'lib' compiler option to 'esnext' or later.
7+
toFromHexBase64.ts(20,20): error TS2550: Property 'setFromHex' does not exist on type 'Uint8Array<ArrayBuffer>'. Do you need to change your target library? Try changing the 'lib' compiler option to 'esnext' or later.
8+
9+
10+
==== toFromHexBase64.ts (7 errors) ====
11+
const arr1 = Uint8Array.fromBase64("AAAAAA==");
12+
~~~~~~~~~~
13+
!!! error TS2339: Property 'fromBase64' does not exist on type 'Uint8ArrayConstructor'.
14+
const arr2 = Uint8Array.fromBase64("AAAAAA", { alphabet: "base64url" });
15+
~~~~~~~~~~
16+
!!! error TS2339: Property 'fromBase64' does not exist on type 'Uint8ArrayConstructor'.
17+
const arr3 = Uint8Array.fromHex("000000");
18+
~~~~~~~
19+
!!! error TS2339: Property 'fromHex' does not exist on type 'Uint8ArrayConstructor'.
20+
21+
const encodedBase64_1 = arr1.toBase64();
22+
const encodedBase64_2 = arr1.toBase64({ alphabet: "base64" });
23+
const encodedBase64_3 = arr1.toBase64({ alphabet: "base64url", omitPadding: true });
24+
25+
const encodedHex_1 = arr1.toHex();
26+
27+
const target1 = new Uint8Array(10);
28+
const r1 = target1.setFromBase64("AAAAAA==");
29+
~~~~~~~~~~~~~
30+
!!! error TS2550: Property 'setFromBase64' does not exist on type 'Uint8Array<ArrayBuffer>'. Do you need to change your target library? Try changing the 'lib' compiler option to 'esnext' or later.
31+
const r2 = target1.setFromBase64("AAAAAA==", { lastChunkHandling: "strict" });
32+
~~~~~~~~~~~~~
33+
!!! error TS2550: Property 'setFromBase64' does not exist on type 'Uint8Array<ArrayBuffer>'. Do you need to change your target library? Try changing the 'lib' compiler option to 'esnext' or later.
34+
const r3 = target1.setFromBase64("AAAAAA", {
35+
~~~~~~~~~~~~~
36+
!!! error TS2550: Property 'setFromBase64' does not exist on type 'Uint8Array<ArrayBuffer>'. Do you need to change your target library? Try changing the 'lib' compiler option to 'esnext' or later.
37+
alphabet: "base64url",
38+
lastChunkHandling: "stop-before-partial"
39+
});
40+
41+
const target2 = new Uint8Array(10);
42+
const r4 = target2.setFromHex("000000");
43+
~~~~~~~~~~
44+
!!! error TS2550: Property 'setFromHex' does not exist on type 'Uint8Array<ArrayBuffer>'. Do you need to change your target library? Try changing the 'lib' compiler option to 'esnext' or later.
45+
46+
const totalWritten = r1.written + r2.written + r3.written + r4.written;
47+
const totalRead = r1.read + r2.read + r3.read + r4.read;
48+
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//// [tests/cases/conformance/esnext/toFromHexBase64.ts] ////
2+
3+
//// [toFromHexBase64.ts]
4+
const arr1 = Uint8Array.fromBase64("AAAAAA==");
5+
const arr2 = Uint8Array.fromBase64("AAAAAA", { alphabet: "base64url" });
6+
const arr3 = Uint8Array.fromHex("000000");
7+
8+
const encodedBase64_1 = arr1.toBase64();
9+
const encodedBase64_2 = arr1.toBase64({ alphabet: "base64" });
10+
const encodedBase64_3 = arr1.toBase64({ alphabet: "base64url", omitPadding: true });
11+
12+
const encodedHex_1 = arr1.toHex();
13+
14+
const target1 = new Uint8Array(10);
15+
const r1 = target1.setFromBase64("AAAAAA==");
16+
const r2 = target1.setFromBase64("AAAAAA==", { lastChunkHandling: "strict" });
17+
const r3 = target1.setFromBase64("AAAAAA", {
18+
alphabet: "base64url",
19+
lastChunkHandling: "stop-before-partial"
20+
});
21+
22+
const target2 = new Uint8Array(10);
23+
const r4 = target2.setFromHex("000000");
24+
25+
const totalWritten = r1.written + r2.written + r3.written + r4.written;
26+
const totalRead = r1.read + r2.read + r3.read + r4.read;
27+
28+
29+
//// [toFromHexBase64.js]
30+
const arr1 = Uint8Array.fromBase64("AAAAAA==");
31+
const arr2 = Uint8Array.fromBase64("AAAAAA", { alphabet: "base64url" });
32+
const arr3 = Uint8Array.fromHex("000000");
33+
const encodedBase64_1 = arr1.toBase64();
34+
const encodedBase64_2 = arr1.toBase64({ alphabet: "base64" });
35+
const encodedBase64_3 = arr1.toBase64({ alphabet: "base64url", omitPadding: true });
36+
const encodedHex_1 = arr1.toHex();
37+
const target1 = new Uint8Array(10);
38+
const r1 = target1.setFromBase64("AAAAAA==");
39+
const r2 = target1.setFromBase64("AAAAAA==", { lastChunkHandling: "strict" });
40+
const r3 = target1.setFromBase64("AAAAAA", {
41+
alphabet: "base64url",
42+
lastChunkHandling: "stop-before-partial"
43+
});
44+
const target2 = new Uint8Array(10);
45+
const r4 = target2.setFromHex("000000");
46+
const totalWritten = r1.written + r2.written + r3.written + r4.written;
47+
const totalRead = r1.read + r2.read + r3.read + r4.read;
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
//// [tests/cases/conformance/esnext/toFromHexBase64.ts] ////
2+
3+
=== toFromHexBase64.ts ===
4+
const arr1 = Uint8Array.fromBase64("AAAAAA==");
5+
>arr1 : Symbol(arr1, Decl(toFromHexBase64.ts, 0, 5))
6+
>Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more)
7+
8+
const arr2 = Uint8Array.fromBase64("AAAAAA", { alphabet: "base64url" });
9+
>arr2 : Symbol(arr2, Decl(toFromHexBase64.ts, 1, 5))
10+
>Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more)
11+
>alphabet : Symbol(alphabet, Decl(toFromHexBase64.ts, 1, 46))
12+
13+
const arr3 = Uint8Array.fromHex("000000");
14+
>arr3 : Symbol(arr3, Decl(toFromHexBase64.ts, 2, 5))
15+
>Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more)
16+
17+
const encodedBase64_1 = arr1.toBase64();
18+
>encodedBase64_1 : Symbol(encodedBase64_1, Decl(toFromHexBase64.ts, 4, 5))
19+
>arr1 : Symbol(arr1, Decl(toFromHexBase64.ts, 0, 5))
20+
21+
const encodedBase64_2 = arr1.toBase64({ alphabet: "base64" });
22+
>encodedBase64_2 : Symbol(encodedBase64_2, Decl(toFromHexBase64.ts, 5, 5))
23+
>arr1 : Symbol(arr1, Decl(toFromHexBase64.ts, 0, 5))
24+
>alphabet : Symbol(alphabet, Decl(toFromHexBase64.ts, 5, 39))
25+
26+
const encodedBase64_3 = arr1.toBase64({ alphabet: "base64url", omitPadding: true });
27+
>encodedBase64_3 : Symbol(encodedBase64_3, Decl(toFromHexBase64.ts, 6, 5))
28+
>arr1 : Symbol(arr1, Decl(toFromHexBase64.ts, 0, 5))
29+
>alphabet : Symbol(alphabet, Decl(toFromHexBase64.ts, 6, 39))
30+
>omitPadding : Symbol(omitPadding, Decl(toFromHexBase64.ts, 6, 62))
31+
32+
const encodedHex_1 = arr1.toHex();
33+
>encodedHex_1 : Symbol(encodedHex_1, Decl(toFromHexBase64.ts, 8, 5))
34+
>arr1 : Symbol(arr1, Decl(toFromHexBase64.ts, 0, 5))
35+
36+
const target1 = new Uint8Array(10);
37+
>target1 : Symbol(target1, Decl(toFromHexBase64.ts, 10, 5))
38+
>Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more)
39+
40+
const r1 = target1.setFromBase64("AAAAAA==");
41+
>r1 : Symbol(r1, Decl(toFromHexBase64.ts, 11, 5))
42+
>target1 : Symbol(target1, Decl(toFromHexBase64.ts, 10, 5))
43+
44+
const r2 = target1.setFromBase64("AAAAAA==", { lastChunkHandling: "strict" });
45+
>r2 : Symbol(r2, Decl(toFromHexBase64.ts, 12, 5))
46+
>target1 : Symbol(target1, Decl(toFromHexBase64.ts, 10, 5))
47+
>lastChunkHandling : Symbol(lastChunkHandling, Decl(toFromHexBase64.ts, 12, 46))
48+
49+
const r3 = target1.setFromBase64("AAAAAA", {
50+
>r3 : Symbol(r3, Decl(toFromHexBase64.ts, 13, 5))
51+
>target1 : Symbol(target1, Decl(toFromHexBase64.ts, 10, 5))
52+
53+
alphabet: "base64url",
54+
>alphabet : Symbol(alphabet, Decl(toFromHexBase64.ts, 13, 44))
55+
56+
lastChunkHandling: "stop-before-partial"
57+
>lastChunkHandling : Symbol(lastChunkHandling, Decl(toFromHexBase64.ts, 14, 24))
58+
59+
});
60+
61+
const target2 = new Uint8Array(10);
62+
>target2 : Symbol(target2, Decl(toFromHexBase64.ts, 18, 5))
63+
>Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more)
64+
65+
const r4 = target2.setFromHex("000000");
66+
>r4 : Symbol(r4, Decl(toFromHexBase64.ts, 19, 5))
67+
>target2 : Symbol(target2, Decl(toFromHexBase64.ts, 18, 5))
68+
69+
const totalWritten = r1.written + r2.written + r3.written + r4.written;
70+
>totalWritten : Symbol(totalWritten, Decl(toFromHexBase64.ts, 21, 5))
71+
>r1 : Symbol(r1, Decl(toFromHexBase64.ts, 11, 5))
72+
>r2 : Symbol(r2, Decl(toFromHexBase64.ts, 12, 5))
73+
>r3 : Symbol(r3, Decl(toFromHexBase64.ts, 13, 5))
74+
>r4 : Symbol(r4, Decl(toFromHexBase64.ts, 19, 5))
75+
76+
const totalRead = r1.read + r2.read + r3.read + r4.read;
77+
>totalRead : Symbol(totalRead, Decl(toFromHexBase64.ts, 22, 5))
78+
>r1 : Symbol(r1, Decl(toFromHexBase64.ts, 11, 5))
79+
>r2 : Symbol(r2, Decl(toFromHexBase64.ts, 12, 5))
80+
>r3 : Symbol(r3, Decl(toFromHexBase64.ts, 13, 5))
81+
>r4 : Symbol(r4, Decl(toFromHexBase64.ts, 19, 5))
82+

0 commit comments

Comments
 (0)