Make tests more strict

In ECMAScript 5, assignment to a non-reference value throws a runtime
ReferenceError. ECMAscript 6 specifies an early ReferenceError in these
cases. Tests for this behavior have been authored to pass in both cases.
Simplify these tests to describe and assert the early error.
This commit is contained in:
Mike Pennisi 2015-06-29 12:09:31 -04:00
parent 408318bfb0
commit 64826c2ad3
32 changed files with 209 additions and 384 deletions

View File

@ -1,24 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator x = y uses GetValue and PutValue
es5id: 11.13.1_A2.1_T3
description: >
If Type(LeftHandSideExpression) is not Reference, throw
ReferenceError
negative: ReferenceError
---*/
//CHECK#1
try {
1 = 1;
$ERROR('#1.1: 1 = 1 throw ReferenceError. Actual: ' + (1 = 1));
}
catch (e) {
if ((e instanceof ReferenceError) !== true) {
$ERROR('#1.2: 1 = 1 throw ReferenceError. Actual: ' + (e));
} else {
1 = 1;
}
}

View File

@ -0,0 +1,14 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
It is an early Reference Error if LeftHandSideExpression is neither an
ObjectLiteral nor an ArrayLiteral and IsValidSimpleAssignmentTarget of
LeftHandSideExpression is false.
es6id: 12.14.1
description: Assignment with non-simple target
negative: ReferenceError
---*/
1 = 1;

View File

@ -1,24 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator uses PutValue
es5id: 11.13.2_A2.2_T1
description: >
If Type(LeftHandSideExpression) is not Reference, throw
ReferenceError. Check operator is "x *= y"
negative: ReferenceError
---*/
//CHECK#1
try {
var z = (1 *= 1);
$ERROR('#1.1: 1 *= 1 throw ReferenceError. Actual: ' + (z));
}
catch (e) {
if ((e instanceof ReferenceError) !== true) {
$ERROR('#1.2: 1 *= 1 throw ReferenceError. Actual: ' + (e));
} else {
var z = (1 *= 1);
}
}

View File

@ -1,24 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator uses PutValue
es5id: 11.13.2_A2.2_T10
description: >
If Type(LeftHandSideExpression) is not Reference, throw
ReferenceError. Check operator is "x ^= y"
negative: ReferenceError
---*/
//CHECK#1
try {
var z = (1 ^= 1);
$ERROR('#1.1: 1 ^= 1 throw ReferenceError. Actual: ' + (z));
}
catch (e) {
if ((e instanceof ReferenceError) !== true) {
$ERROR('#1.2: 1 ^= 1 throw ReferenceError. Actual: ' + (e));
} else {
var z = (1 ^= 1);
}
}

View File

@ -1,24 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator uses PutValue
es5id: 11.13.2_A2.2_T11
description: >
If Type(LeftHandSideExpression) is not Reference, throw
ReferenceError. Check operator is "x |= y"
negative: ReferenceError
---*/
//CHECK#1
try {
var z = (1 |= 1);
$ERROR('#1.1: 1 |= 1 throw ReferenceError. Actual: ' + (z));
}
catch (e) {
if ((e instanceof ReferenceError) !== true) {
$ERROR('#1.2: 1 |= 1 throw ReferenceError. Actual: ' + (e));
} else {
var z = (1 |= 1);
}
}

View File

@ -1,24 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator uses PutValue
es5id: 11.13.2_A2.2_T2
description: >
If Type(LeftHandSideExpression) is not Reference, throw
ReferenceError. Check operator is "x /= y"
negative: ReferenceError
---*/
//CHECK#1
try {
var z = (1 /= 1);
$ERROR('#1.1: 1 /= 1 throw ReferenceError. Actual: ' + (z));
}
catch (e) {
if ((e instanceof ReferenceError) !== true) {
$ERROR('#1.2: 1 /= 1 throw ReferenceError. Actual: ' + (e));
} else {
var z = (1 /= 1);
}
}

View File

@ -1,24 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator uses PutValue
es5id: 11.13.2_A2.2_T3
description: >
If Type(LeftHandSideExpression) is not Reference, throw
ReferenceError. Check operator is "x %= y"
negative: ReferenceError
---*/
//CHECK#1
try {
var z = (1 %= 1);
$ERROR('#1.1: 1 %= 1 throw ReferenceError. Actual: ' + (z));
}
catch (e) {
if ((e instanceof ReferenceError) !== true) {
$ERROR('#1.2: 1 %= 1 throw ReferenceError. Actual: ' + (e));
} else {
var z = (1 %= 1);
}
}

View File

@ -1,24 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator uses PutValue
es5id: 11.13.2_A2.2_T4
description: >
If Type(LeftHandSideExpression) is not Reference, throw
ReferenceError. Check operator is "x += y"
negative: ReferenceError
---*/
//CHECK#1
try {
var z = (1 += 1);
$ERROR('#1.1: 1 += 1 throw ReferenceError. Actual: ' + (z));
}
catch (e) {
if ((e instanceof ReferenceError) !== true) {
$ERROR('#1.2: 1 += 1 throw ReferenceError. Actual: ' + (e));
} else {
var z = (1 += 1);
}
}

View File

@ -1,24 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator uses PutValue
es5id: 11.13.2_A2.2_T5
description: >
If Type(LeftHandSideExpression) is not Reference, throw
ReferenceError. Check operator is "x -= y"
negative: ReferenceError
---*/
//CHECK#1
try {
var z = (1 -= 1);
$ERROR('#1.1: 1 -= 1 throw ReferenceError. Actual: ' + (z));
}
catch (e) {
if ((e instanceof ReferenceError) !== true) {
$ERROR('#1.2: 1 -= 1 throw ReferenceError. Actual: ' + (e));
} else {
var z = (1 -= 1);
}
}

View File

@ -1,24 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator uses PutValue
es5id: 11.13.2_A2.2_T6
description: >
If Type(LeftHandSideExpression) is not Reference, throw
ReferenceError. Check operator is "x <<= y"
negative: ReferenceError
---*/
//CHECK#1
try {
var z = (1 <<= 1);
$ERROR('#1.1: 1 <<= 1 throw ReferenceError. Actual: ' + (z));
}
catch (e) {
if ((e instanceof ReferenceError) !== true) {
$ERROR('#1.2: 1 <<= 1 throw ReferenceError. Actual: ' + (e));
} else {
var z = (1 <<= 1);
}
}

View File

@ -1,24 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator uses PutValue
es5id: 11.13.2_A2.2_T7
description: >
If Type(LeftHandSideExpression) is not Reference, throw
ReferenceError. Check operator is "x >>= y"
negative: ReferenceError
---*/
//CHECK#1
try {
var z = (1 >>= 1);
$ERROR('#1.1: 1 >>= 1 throw ReferenceError. Actual: ' + (z));
}
catch (e) {
if ((e instanceof ReferenceError) !== true) {
$ERROR('#1.2: 1 >>= 1 throw ReferenceError. Actual: ' + (e));
} else {
var z = (1 >>= 1);
}
}

View File

@ -1,24 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator uses PutValue
es5id: 11.13.2_A2.2_T8
description: >
If Type(LeftHandSideExpression) is not Reference, throw
ReferenceError. Check operator is "x >>>= y"
negative: ReferenceError
---*/
//CHECK#1
try {
var z = (1 >>>= 1);
$ERROR('#1.1: 1 >>>= 1 throw ReferenceError. Actual: ' + (z));
}
catch (e) {
if ((e instanceof ReferenceError) !== true) {
$ERROR('#1.2: 1 >>>= 1 throw ReferenceError. Actual: ' + (e));
} else {
var z = (1 >>>= 1);
}
}

View File

@ -1,24 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator uses PutValue
es5id: 11.13.2_A2.2_T9
description: >
If Type(LeftHandSideExpression) is not Reference, throw
ReferenceError. Check operator is "x &= y"
negative: ReferenceError
---*/
//CHECK#1
try {
var z = (1 &= 1);
$ERROR('#1.1: 1 &= 1 throw ReferenceError. Actual: ' + (z));
}
catch (e) {
if ((e instanceof ReferenceError) !== true) {
$ERROR('#1.2: 1 &= 1 throw ReferenceError. Actual: ' + (e));
} else {
var z = (1 &= 1);
}
}

View File

@ -0,0 +1,13 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
It is an early Reference Error if IsValidSimpleAssignmentTarget of
LeftHandSideExpression is false.
es6id: 12.14.1
description: Compound addition assignment with non-simple target
negative: ReferenceError
---*/
1 += 1;

View File

@ -0,0 +1,13 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
It is an early Reference Error if IsValidSimpleAssignmentTarget of
LeftHandSideExpression is false.
es6id: 12.14.1
description: Compound "bitwise and" assignment with non-simple target
negative: ReferenceError
---*/
1 &= 1;

View File

@ -0,0 +1,13 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
It is an early Reference Error if IsValidSimpleAssignmentTarget of
LeftHandSideExpression is false.
es6id: 12.14.1
description: Compound "bitwise or" assignment with non-simple target
negative: ReferenceError
---*/
1 |= 1;

View File

@ -0,0 +1,13 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
It is an early Reference Error if IsValidSimpleAssignmentTarget of
LeftHandSideExpression is false.
es6id: 12.14.1
description: Compound "bitwise xor" assignment with non-simple target
negative: ReferenceError
---*/
1 ^= 1;

View File

@ -0,0 +1,13 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
It is an early Reference Error if IsValidSimpleAssignmentTarget of
LeftHandSideExpression is false.
es6id: 12.14.1
description: Compound division assignment with non-simple target
negative: ReferenceError
---*/
1 /= 1;

View File

@ -0,0 +1,13 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
It is an early Reference Error if IsValidSimpleAssignmentTarget of
LeftHandSideExpression is false.
es6id: 12.14.1
description: Compound "left shift" assignment with non-simple target
negative: ReferenceError
---*/
1 <<= 1;

View File

@ -0,0 +1,13 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
It is an early Reference Error if IsValidSimpleAssignmentTarget of
LeftHandSideExpression is false.
es6id: 12.14.1
description: Compound "modular division" assignment with non-simple target
negative: ReferenceError
---*/
1 %= 1;

View File

@ -0,0 +1,13 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
It is an early Reference Error if IsValidSimpleAssignmentTarget of
LeftHandSideExpression is false.
es6id: 12.14.1
description: Compound multiplication assignment with non-simple target
negative: ReferenceError
---*/
1 *= 1;

View File

@ -0,0 +1,13 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
It is an early Reference Error if IsValidSimpleAssignmentTarget of
LeftHandSideExpression is false.
es6id: 12.14.1
description: Compound "right shift" assignment with non-simple target
negative: ReferenceError
---*/
1 >>= 1;

View File

@ -0,0 +1,13 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
It is an early Reference Error if IsValidSimpleAssignmentTarget of
LeftHandSideExpression is false.
es6id: 12.14.1
description: Compound subtraction assignment with non-simple target
negative: ReferenceError
---*/
1 -= 1;

View File

@ -0,0 +1,13 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
It is an early Reference Error if IsValidSimpleAssignmentTarget of
LeftHandSideExpression is false.
es6id: 12.14.1
description: Compound "unsigned right shift" assignment with non-simple target
negative: ReferenceError
---*/
1 >>>= 1;

View File

@ -1,24 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
Operator x-- uses GetValue and PutValue
ES6, 12.4.1 and 12.5.1 specify ReferenceError
es5id: 11.3.2_A2.1_T3
description: If Type(x) is not Reference, throw ReferenceError
negative: ReferenceError
---*/
//CHECK#1
try {
1--;
$ERROR('#1.1: 1-- throw ReferenceError. Actual: ' + (1--));
}
catch (e) {
if ((e instanceof ReferenceError) !== true) {
$ERROR('#1.2: 1-- throw ReferenceError. Actual: ' + (e));
} else {
1--;
}
}

View File

@ -0,0 +1,13 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
It is an early Reference Error if IsValidSimpleAssignmentTarget of
LeftHandSideExpression is false.
es6id: 12.4.1
description: Applied to a non-simple assignment target
negative: ReferenceError
---*/
1--;

View File

@ -1,24 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
Operator x++ uses GetValue and PutValue
ES6, 12.4.1 and 12.5.1 specify ReferenceError
es5id: 11.3.1_A2.1_T3
description: If Type(x) is not Reference, throw ReferenceError
negative: ReferenceError
---*/
//CHECK#1
try {
1++;
$ERROR('#1.1: 1++ throw ReferenceError. Actual: ' + (1++));
}
catch (e) {
if ((e instanceof ReferenceError) !== true) {
$ERROR('#1.2: 1++ throw ReferenceError. Actual: ' + (e));
} else {
1++;
}
}

View File

@ -0,0 +1,13 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
It is an early Reference Error if IsValidSimpleAssignmentTarget of
LeftHandSideExpression is false.
es6id: 12.4.1
description: Applied to a non-simple assignment target
negative: ReferenceError
---*/
1++;

View File

@ -1,24 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
Operator --x uses GetValue and PutValue
ES6 12.5.1 specifies this as ReferenceError
es5id: 11.4.5_A2.1_T3
description: If Type(x) is not Reference, throw ReferenceError
negative: ReferenceError
---*/
//CHECK#1
try {
--1;
$ERROR('#1.1: --1 throw ReferenceError. Actual: ' + (--1));
}
catch (e) {
if ((e instanceof ReferenceError) !== true) {
$ERROR('#1.2: --1 throw ReferenceError. Actual: ' + (e));
} else {
--1;
}
}

View File

@ -0,0 +1,13 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
It is an early Reference Error if IsValidSimpleAssignmentTarget of
UnaryExpression is false.
es5id: 12.5.1
description: Applied to a non-simple assignment target
negative: ReferenceError
---*/
--1;

View File

@ -1,24 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
Operator ++x uses GetValue and PutValue
ES6, 12.4.1 and 12.5.1 specify ReferenceError
es5id: 11.4.4_A2.1_T3
description: If Type(x) is not Reference, throw ReferenceError
negative: ReferenceError
---*/
//CHECK#1
try {
++1;
$ERROR('#1.1: ++1 throw ReferenceError. Actual: ' + (++1));
}
catch (e) {
if ((e instanceof ReferenceError) !== true) {
$ERROR('#1.2: ++1 throw ReferenceError. Actual: ' + (e));
} else {
++1;
}
}

View File

@ -0,0 +1,13 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
It is an early Reference Error if IsValidSimpleAssignmentTarget of
UnaryExpression is false.
es6id: 12.5.1
description: Applied to a non-simple assignment target
negative: ReferenceError
---*/
++1;