From 4efa61cf80aa66512a892f8db40bfa1aee1c0fe7 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 6 Dec 2016 13:05:52 -0800 Subject: [PATCH] More tests for binding elements referencing previous elements --- .../destructuringArrayBindingPatternAndAssignment3.ts | 10 ++++++++-- .../destructuringObjectBindingPatternAndAssignment4.ts | 8 ++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment4.ts diff --git a/tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment3.ts b/tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment3.ts index f0537456891..243a297ed43 100644 --- a/tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment3.ts +++ b/tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment3.ts @@ -1,4 +1,10 @@ const [a, b = a] = [1]; // ok -const [a, b = a, c = c] = [1]; // error for c -const [a, b = a, c = d, d = a] = [1]; // error for c +const [c, d = c, e = e] = [1]; // error for e = e +const [f, g = f, h = i, i = f] = [1]; // error for h = i +(function ([a, b = a]) { // ok +})([1]); +(function ([c, d = c, e = e]) { // error for e = e +})([1]); +(function ([f, g = f, h = i, i = f]) { // error for h = i +})([1]) diff --git a/tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment4.ts b/tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment4.ts new file mode 100644 index 00000000000..d138c14db7a --- /dev/null +++ b/tests/cases/conformance/es6/destructuring/destructuringObjectBindingPatternAndAssignment4.ts @@ -0,0 +1,8 @@ +const { + a = 1, + b = 2, + c = b, // ok + d = a, // ok + e = f, // error + f = f // error +} = { } as any;