Add missing tests for statement completion values

The project contains tests for the completion value of most (but not
all) statements. Introduce tests to complete coverage of this detail.
This commit is contained in:
Mike Pennisi 2016-06-30 10:45:02 -04:00
parent b0072ca1b5
commit ec9d79c027
6 changed files with 151 additions and 0 deletions

View File

@ -0,0 +1,25 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-let-and-const-declarations-runtime-semantics-evaluation
es6id: 13.3.1.4
description: Returns an empty completion
info: |
LexicalDeclaration : LetOrConst BindingList ;
1. Let next be the result of evaluating BindingList.
2. ReturnIfAbrupt(next).
3. Return NormalCompletion(empty).
---*/
assert.sameValue(
eval('const test262id1 = 1;'), undefined, 'Single declaration'
);
assert.sameValue(
eval('const test262id2 = 2, test262id3 = 3;'),
undefined,
'Multiple declarations'
);
assert.sameValue(eval('4; const test262id5 = 5;'), 4);
assert.sameValue(eval('6; let test262id7 = 7, test262id8 = 8;'), 6);

View File

@ -0,0 +1,13 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-empty-statement-runtime-semantics-evaluation
es6id: 13.4.1
description: Returns an empty completion
info: |
1. Return NormalCompletion(empty).
---*/
assert.sameValue(eval(';'), undefined);
assert.sameValue(eval('2;;'), 2);
assert.sameValue(eval('3;;;'), 3);

View File

@ -0,0 +1,19 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-labelled-statements-runtime-semantics-labelledevaluation
es6id: 13.13.14
description: Completion value when LabelledItem returns a "break" completion
info: |
LabelledStatement : LabelIdentifier : LabelledItem
1. Let label be the StringValue of LabelIdentifier.
2. Append label as an element of labelSet.
3. Let stmtResult be LabelledEvaluation of LabelledItem with argument
labelSet.
4. If stmtResult.[[Type]] is break and SameValue(stmtResult.[[Target]],
label) is true, then
a. Let stmtResult be NormalCompletion(stmtResult.[[Value]]).
---*/
assert.sameValue(eval('test262id: { 5; break test262id; 9; }'), 5);

View File

@ -0,0 +1,20 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-labelled-statements-runtime-semantics-labelledevaluation
es6id: 13.13.14
description: Completion value when LabelledItem returns normally
info: |
LabelledStatement : LabelIdentifier : LabelledItem
1. Let label be the StringValue of LabelIdentifier.
2. Append label as an element of labelSet.
3. Let stmtResult be LabelledEvaluation of LabelledItem with argument
labelSet.
4. If stmtResult.[[Type]] is break and SameValue(stmtResult.[[Target]],
label) is true, then
[...]
5. Return Completion(stmtResult).
---*/
assert.sameValue(eval('test262id: 2;'), 2);

View File

@ -0,0 +1,37 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-let-and-const-declarations-runtime-semantics-evaluation
es6id: 13.3.1.4
description: Returns an empty completion
info: |
LexicalDeclaration : LetOrConst BindingList ;
1. Let next be the result of evaluating BindingList.
2. ReturnIfAbrupt(next).
3. Return NormalCompletion(empty).
---*/
assert.sameValue(
eval('let test262id1;'), undefined, 'Single declaration without initializer'
);
assert.sameValue(
eval('let test262id2 = 2;'),
undefined,
'Single declaration bearing initializer'
);
assert.sameValue(
eval('let test262id3 = 3, test262id4;'),
undefined,
'Multiple declarations, final without initializer'
);
assert.sameValue(
eval('let test262id5, test262id6 = 6;'),
undefined,
'Multiple declarations, final bearing initializer'
);
assert.sameValue(eval('7; let test262id8;'), 7);
assert.sameValue(eval('9; let test262id10 = 10;'), 9);
assert.sameValue(eval('11; let test262id12 = 12, test262id13;'), 11);
assert.sameValue(eval('14; let test262id15, test262id16 = 16;'), 14);

View File

@ -0,0 +1,37 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-variable-statement-runtime-semantics-evaluation
es6id: 13.3.2.4
description: Returns an empty completion
info: |
VariableStatement : var VariableDeclarationList ;
1. Let next be the result of evaluating VariableDeclarationList.
2. ReturnIfAbrupt(next).
3. Return NormalCompletion(empty).
---*/
assert.sameValue(
eval('var test262id1;'), undefined, 'Single declaration without initializer'
);
assert.sameValue(
eval('var test262id2 = 2;'),
undefined,
'Single declaration bearing initializer'
);
assert.sameValue(
eval('var test262id3 = 3, test262id4;'),
undefined,
'Multiple declarations, final without initializer'
);
assert.sameValue(
eval('var test262id5, test262id6 = 6;'),
undefined,
'Multiple declarations, final bearing initializer'
);
assert.sameValue(eval('7; var test262id8;'), 7);
assert.sameValue(eval('9; var test262id10 = 10;'), 9);
assert.sameValue(eval('11; var test262id12 = 12, test262id13;'), 11);
assert.sameValue(eval('14; var test262id15, test262id16 = 16;'), 14);