Add tests for delete expression returning true on non reference types

This commit is contained in:
Leo Balter 2018-10-16 16:54:56 -04:00 committed by Rick Waldron
parent 1f83526476
commit 2ac5f1766e
6 changed files with 34 additions and 57 deletions

View File

@ -1,11 +0,0 @@
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 11.4.1-2-1
description: delete operator returns true when deleting a non-reference (number)
---*/
var d = delete 42;
assert.sameValue(d, true, 'd');

View File

@ -1,13 +0,0 @@
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 11.4.1-2-3
description: >
delete operator returns true when deleting a non-reference
(boolean)
---*/
var d = delete true;
assert.sameValue(d, true, 'd');

View File

@ -1,11 +0,0 @@
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 11.4.1-2-4
description: delete operator returns true when deleting a non-reference (string)
---*/
var d = delete "abc";
assert.sameValue(d, true, 'd');

View File

@ -1,11 +0,0 @@
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 11.4.1-2-5
description: delete operator returns true when deleting a non-reference (obj)
---*/
var d = delete {a:0} ;
assert.sameValue(d, true, 'd');

View File

@ -1,11 +0,0 @@
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 11.4.1-2-6
description: delete operator returns true when deleting a non-reference (null)
---*/
var d = delete null;
assert.sameValue(d, true, 'd');

View File

@ -0,0 +1,34 @@
// Copyright (c) 2018 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-delete-operator-runtime-semantics-evaluation
description: >
The delete expression should return true if the right hand UnaryExpression is not a Reference
info: |
Runtime Semantics: Evaluation
UnaryExpression : delete UnaryExpression
1. Let ref be the result of evaluating UnaryExpression.
2. ReturnIfAbrupt(ref).
3. If Type(ref) is not Reference, return true.
---*/
var a = { b: 42 };
assert.sameValue(delete void a.b, true, 'delete void a.b');
assert.sameValue(delete void 0, true, 'delete void 0');
assert.sameValue(delete typeof 0, true, 'delete typeof 0');
assert.sameValue(delete delete 0, true, 'delete delete 0');
assert.sameValue(delete void typeof +-~!0, true, 'delete void typeof +-~!0');
assert.sameValue(delete {x:1}, true, 'delete {x:1}');
assert.sameValue(delete null, true, 'delete null');
assert.sameValue(delete true, true, 'delete true');
assert.sameValue(delete false, true, 'delete false');
assert.sameValue(delete 0, true, 'delete 0');
assert.sameValue(delete 1, true, 'delete 1');
assert.sameValue(delete '', true, 'delete ""');
assert.sameValue(delete 'Test262', true, 'delete "Test262"');
assert.sameValue(delete typeof +-~!0, true, 'delete typeof +-~!0');
assert.sameValue(delete +-~!0, true, 'delete +-~!0');
assert.sameValue(delete -~!0, true, 'delete -~!0');
assert.sameValue(delete ~!0, true, 'delete ~!0');
assert.sameValue(delete !0, true, 'delete !0');