From 33f488354cf28e326d53e51edb50036005882933 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 28 May 2018 13:17:13 -0400 Subject: Move testdata/read_file_sync.ts to tests.ts We don't need to start a new process for every test. --- testdata/read_file_sync.ts | 14 -------------- testdata/read_file_sync.ts.out | 1 - tests.ts | 23 ++++++++++++++++++++--- 3 files changed, 20 insertions(+), 18 deletions(-) delete mode 100644 testdata/read_file_sync.ts delete mode 100644 testdata/read_file_sync.ts.out diff --git a/testdata/read_file_sync.ts b/testdata/read_file_sync.ts deleted file mode 100644 index cb0904d35..000000000 --- a/testdata/read_file_sync.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { readFileSync } from "deno"; - -let data = readFileSync("package.json"); -if (!data.byteLength) { - throw Error(`Expected positive value for data.byteLength ${data.byteLength}`); -} - -const decoder = new TextDecoder("utf-8"); -const json = decoder.decode(data); -const pkg = JSON.parse(json); -if (pkg.name !== "deno") { - throw Error(`Expected "deno" but got "${pkg.name}"`) -} -console.log("package.name ", pkg.name); diff --git a/testdata/read_file_sync.ts.out b/testdata/read_file_sync.ts.out deleted file mode 100644 index 53d818f44..000000000 --- a/testdata/read_file_sync.ts.out +++ /dev/null @@ -1 +0,0 @@ -package.name deno diff --git a/tests.ts b/tests.ts index b9fcbf37f..59aeafcf8 100644 --- a/tests.ts +++ b/tests.ts @@ -1,5 +1,22 @@ -import { test, assert } from "./deno_testing/testing.ts"; +// This test is executed as part of integration_test.go +// But it can also be run manually: +// ./deno tests.ts +import { test, assert, assertEqual } from "./deno_testing/testing.ts"; +import { readFileSync } from "deno"; -test(async function test_matchTesters() { - assert(false, "assert failed on purpose."); +test(async function tests_test() { + assert(true); +}); + +test(async function tests_readFileSync() { + let data = readFileSync("package.json"); + if (!data.byteLength) { + throw Error( + `Expected positive value for data.byteLength ${data.byteLength}` + ); + } + const decoder = new TextDecoder("utf-8"); + const json = decoder.decode(data); + const pkg = JSON.parse(json); + assertEqual(pkg.name, "deno"); }); -- cgit v1.2.3