From e6d1e39fb7de43177a54a730209c648b76396b58 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Wed, 3 Dec 2014 21:07:50 -0800 Subject: [PATCH] Add more coverage tests. --- src/compiler/checker.ts | 10 ++++------ src/harness/harness.ts | 6 ++---- .../reference/throwWithoutNewLine2.errors.txt | 11 +++++++++++ tests/cases/compiler/throwWithoutNewLine2.ts | 2 ++ 4 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 tests/baselines/reference/throwWithoutNewLine2.errors.txt create mode 100644 tests/cases/compiler/throwWithoutNewLine2.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fc67faa8f8..fad43b8dd8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1033,10 +1033,6 @@ module ts { writer.writePunctuation(tokenToString(kind)); } - function writeOperator(writer: SymbolWriter, kind: SyntaxKind) { - writer.writeOperator(tokenToString(kind)); - } - function writeSpace(writer: SymbolWriter) { writer.writeSpace(" "); } @@ -7820,8 +7816,10 @@ module ts { } function checkThrowStatement(node: ThrowStatement) { - checkExpression(node.expression); - } + if (node.expression) { + checkExpression(node.expression); + } +} function checkTryStatement(node: TryStatement) { checkBlock(node.tryBlock); diff --git a/src/harness/harness.ts b/src/harness/harness.ts index c0d3ddedce..c44649a6ee 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -27,6 +27,7 @@ var _chai: typeof chai = require('chai'); var assert: typeof _chai.assert = _chai.assert; declare var __dirname: any; // Node-specific var global = Function("return this").call(null); +var typescript = require('./typescriptServices'); module Utils { var global = Function("return this").call(null); @@ -1389,7 +1390,4 @@ module Harness { } if (Error) (Error).stackTraceLimit = 1; -} - -// TODO: not sure why Utils.evalFile isn't working with this, eventually will concat it like old compiler instead of eval -eval(Harness.tcServicesFile); +} \ No newline at end of file diff --git a/tests/baselines/reference/throwWithoutNewLine2.errors.txt b/tests/baselines/reference/throwWithoutNewLine2.errors.txt new file mode 100644 index 0000000000..6930d240e7 --- /dev/null +++ b/tests/baselines/reference/throwWithoutNewLine2.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/throwWithoutNewLine2.ts(1,6): error TS1142: Line break not permitted here. +tests/cases/compiler/throwWithoutNewLine2.ts(2,1): error TS2304: Cannot find name 'a'. + + +==== tests/cases/compiler/throwWithoutNewLine2.ts (2 errors) ==== + throw + +!!! error TS1142: Line break not permitted here. + a; + ~ +!!! error TS2304: Cannot find name 'a'. \ No newline at end of file diff --git a/tests/cases/compiler/throwWithoutNewLine2.ts b/tests/cases/compiler/throwWithoutNewLine2.ts new file mode 100644 index 0000000000..731b23ecb4 --- /dev/null +++ b/tests/cases/compiler/throwWithoutNewLine2.ts @@ -0,0 +1,2 @@ +throw +a; \ No newline at end of file