From e59ba41d17097419b4b60902b6d00aba86633d25 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Tue, 9 Dec 2014 17:09:33 -0800 Subject: [PATCH] Add incremental test. --- tests/cases/unittests/incrementalParser.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/cases/unittests/incrementalParser.ts b/tests/cases/unittests/incrementalParser.ts index df4c6fdc694..ad4d2c01c7a 100644 --- a/tests/cases/unittests/incrementalParser.ts +++ b/tests/cases/unittests/incrementalParser.ts @@ -300,5 +300,20 @@ module ts { // Note the decreased reuse of nodes compared to 'Strict mode 1' compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); }); + + it('Strict mode 3',() => { + // In non-strict mode 'package' means nothing and can be reused. In strict mode though + // we'll have to reparse the nodes (and generate an error for 'package();' + // + // Note: in this test we don't actually remove 'use strict'. This is so we can compare + // reuse with/without a strict mode change. + var source = "'strict';\r\nfoo1();\r\nfoo1();\r\nfoo1();\r\npackage();"; + + var index = source.indexOf('f'); + var oldText = ScriptSnapshot.fromString(source); + var newTextAndChange = withDelete(oldText, 0, index); + + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); + }); }); } \ No newline at end of file