summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Golovin <golovim@gmail.com>2019-01-29 00:41:29 +0300
committerRyan Dahl <ry@tinyclouds.org>2019-01-28 16:41:29 -0500
commitf05fd7a1f3a1114b3d525613d96f85967c224815 (patch)
tree6d0acc586f8bfebe427ad96d4e78e15898c13130 /tests
parent7c4265159a26d2abff51c088f485fe09e9766856 (diff)
Add console.table (#1608)
Diffstat (limited to 'tests')
-rw-r--r--tests/console_table.test3
-rw-r--r--tests/console_table.ts18
-rw-r--r--tests/console_table.ts.out71
3 files changed, 92 insertions, 0 deletions
diff --git a/tests/console_table.test b/tests/console_table.test
new file mode 100644
index 000000000..4f2c5c4ac
--- /dev/null
+++ b/tests/console_table.test
@@ -0,0 +1,3 @@
+args: tests/console_table.ts --reload
+check_stderr: true
+output: tests/console_table.ts.out
diff --git a/tests/console_table.ts b/tests/console_table.ts
new file mode 100644
index 000000000..6ff391d99
--- /dev/null
+++ b/tests/console_table.ts
@@ -0,0 +1,18 @@
+console.table({ a: "test", b: 1 });
+console.table({ a: { b: 10 }, b: { b: 20, c: 30 } }, ["c"]);
+console.table([1, 2, [3, [4]], [5, 6], [[7], [8]]]);
+console.table(new Set([1, 2, 3, "test"]));
+console.table(new Map([[1, "one"], [2, "two"]]));
+console.table({
+ a: true,
+ b: { c: { d: 10 }, e: [1, 2, [5, 6]] },
+ f: "test",
+ g: new Set([1, 2, 3, "test"]),
+ h: new Map([[1, "one"]])
+});
+console.table([1, "test", false, { a: 10 }, ["test", { b: 20, c: "test" }]]);
+console.table([]);
+console.table({});
+console.table(new Set());
+console.table(new Map());
+console.table("test");
diff --git a/tests/console_table.ts.out b/tests/console_table.ts.out
new file mode 100644
index 000000000..b4651bc65
--- /dev/null
+++ b/tests/console_table.ts.out
@@ -0,0 +1,71 @@
+Compiling [WILDCARD].ts
+┌─────────┬────────┐
+│ (index) │ Values │
+├─────────┼────────┤
+│ a │ "test" │
+│ b │ 1 │
+└─────────┴────────┘
+┌─────────┬────┐
+│ (index) │ c │
+├─────────┼────┤
+│ a │ │
+│ b │ 30 │
+└─────────┴────┘
+┌─────────┬───────┬───────┬────────┐
+│ (index) │ 0 │ 1 │ Values │
+├─────────┼───────┼───────┼────────┤
+│ 0 │ │ │ 1 │
+│ 1 │ │ │ 2 │
+│ 2 │ 3 │ [ 4 ] │ │
+│ 3 │ 5 │ 6 │ │
+│ 4 │ [ 7 ] │ [ 8 ] │ │
+└─────────┴───────┴───────┴────────┘
+┌───────────────────┬────────┐
+│ (iteration index) │ Values │
+├───────────────────┼────────┤
+│ 0 │ 1 │
+│ 1 │ 2 │
+│ 2 │ 3 │
+│ 3 │ "test" │
+└───────────────────┴────────┘
+┌───────────────────┬───────┬────────┐
+│ (iteration index) │ Key │ Values │
+├───────────────────┼───────┼────────┤
+│ 0 │ "one" │ 1 │
+│ 1 │ "two" │ 2 │
+└───────────────────┴───────┴────────┘
+┌─────────┬───────────┬───────────────────┬────────┐
+│ (index) │ c │ e │ Values │
+├─────────┼───────────┼───────────────────┼────────┤
+│ a │ │ │ true │
+│ b │ { d: 10 } │ [ 1, 2, [Array] ] │ │
+│ f │ │ │ "test" │
+│ g │ │ │ │
+│ h │ │ │ │
+└─────────┴───────────┴───────────────────┴────────┘
+┌─────────┬────────┬──────────────────────┬────┬────────┐
+│ (index) │ 0 │ 1 │ a │ Values │
+├─────────┼────────┼──────────────────────┼────┼────────┤
+│ 0 │ │ │ │ 1 │
+│ 1 │ │ │ │ "test" │
+│ 2 │ │ │ │ false │
+│ 3 │ │ │ 10 │ │
+│ 4 │ "test" │ { b: 20, c: "test" } │ │ │
+└─────────┴────────┴──────────────────────┴────┴────────┘
+┌─────────┐
+│ (index) │
+├─────────┤
+└─────────┘
+┌─────────┐
+│ (index) │
+├─────────┤
+└─────────┘
+┌───────────────────┐
+│ (iteration index) │
+├───────────────────┤
+└───────────────────┘
+┌───────────────────┐
+│ (iteration index) │
+├───────────────────┤
+└───────────────────┘
+test