diff options
author | Aaron Power <theaaronepower@gmail.com> | 2018-08-27 19:59:38 +0100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-08-27 17:18:37 -0400 |
commit | f43259e5abdbf8f80418382349da79b8426dff27 (patch) | |
tree | dd0684f633470f7f55becee738027bb0f3e602f7 /js/unit_tests.ts | |
parent | 0f1db89aa664fe05efae2136d7456465403df30f (diff) |
Moved console tests to own file, and switched circular test to use stringify with assertEqual
Diffstat (limited to 'js/unit_tests.ts')
-rw-r--r-- | js/unit_tests.ts | 79 |
1 files changed, 1 insertions, 78 deletions
diff --git a/js/unit_tests.ts b/js/unit_tests.ts index 48b7e6bb3..bbe93f5e1 100644 --- a/js/unit_tests.ts +++ b/js/unit_tests.ts @@ -5,92 +5,15 @@ import { test, assert, assertEqual } from "./testing/testing.ts"; import { readFileSync } from "deno"; -import { stringify } from "./console.ts"; import * as deno from "deno"; import "./compiler_test.ts"; +import "./console_test.ts"; test(async function tests_test() { assert(true); }); -test(function tests_console_assert() { - console.assert(true); - - let hasThrown = false; - try { - console.assert(false); - } catch { - hasThrown = true; - } - assertEqual(hasThrown, true); -}); - -test(function tests_console_stringify_complex_objects() { - // tslint:disable:no-any - assertEqual("foo", stringify(new Set<any>(), "foo")); - assertEqual(`[ "foo", "bar" ]`, stringify(new Set<any>(), ["foo", "bar"])); - assertEqual(`{ foo: "bar" }`, stringify(new Set<any>(), { foo: "bar" })); - // tslint:enable:no-any -}); - -test(function tests_console_stringify_circular() { - class Base { - a = 1; - m1() {} - } - - class Extended extends Base { - b = 2; - m2() {} - } - - // tslint:disable-next-line:no-any - const nestedObj: any = { - num: 1, - bool: true, - str: "a", - method() {}, - un: undefined, - nu: null, - arrowFunc: () => {}, - extendedClass: new Extended(), - nFunc: new Function(), - extendedCstr: Extended - }; - - const circularObj = { - num: 2, - bool: false, - str: "b", - method() {}, - un: undefined, - nu: null, - nested: nestedObj, - emptyObj: {}, - arr: [1, "s", false, null, nestedObj], - baseClass: new Base() - }; - - nestedObj.o = circularObj; - - try { - console.log(1); - console.log("s"); - console.log(false); - console.log(Symbol(1)); - console.log(null); - console.log(undefined); - console.log(new Extended()); - console.log(function f() {}); - console.log(nestedObj); - console.log(JSON); - console.log(console); - } catch { - throw new Error("Expected no crash on circular object"); - } -}); - test(async function tests_readFileSync() { const data = readFileSync("package.json"); if (!data.byteLength) { |