Skip to content
Snippets Groups Projects
Commit 64826c2a authored by Mike Pennisi's avatar Mike Pennisi
Browse files

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.
parent 408318bf
No related branches found
No related tags found
No related merge requests found
Showing
with 105 additions and 288 deletions
// 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;
}
}
......@@ -3,22 +3,12 @@
/*---
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
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
---*/
//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--;
}
}
1 = 1;
// 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);
}
}
// 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);
}
}
// 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);
}
}
// 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);
}
}
// 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);
}
}
// 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);
}
}
// 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);
}
}
// 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);
}
}
// 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);
}
}
// 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);
}
}
// 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);
}
}
......@@ -3,22 +3,11 @@
/*---
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
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
---*/
//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;
}
}
1 += 1;
// 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;
// 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;
// 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;
// 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;
// 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;
// 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;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment