Skip to content
Snippets Groups Projects
Commit 04f46854 authored by smikes's avatar smikes
Browse files

batch of generator tests

fix info, desc

remove dubious test

correct no-name test, add implicit-name test
parent 8eb0bd12
No related branches found
No related tags found
No related merge requests found
Showing
with 198 additions and 0 deletions
// Copyright 2015 Cubane Canada, Inc. All rights reserved.
// See LICENSE for details.
/*---
info: >
Generator can be declared with GeneratorDeclaration syntax
es6id: 14.4
author: Sam Mikes
description: can declare generator functions
---*/
function *foo(a) { yield a+1; return; }
var g = foo(3);
assert.sameValue(g.next().value, 4);
assert.sameValue(g.next().done, true);
// Copyright 2015 Cubane Canada, Inc. All rights reserved.
// See LICENSE for details.
/*---
info: >
GeneratorMethod early SyntaxError when super is called
directly inside generator args
es6id: 14.4.1
author: Sam Mikes
description: GeneratorMethod error if HasDirectSuper in args
negative: SyntaxError
---*/
var obj = {
*foo(a = super) {
}
};
// Copyright 2015 Cubane Canada, Inc. All rights reserved.
// See LICENSE for details.
/*---
info: >
GeneratorMethod can reference SuperProperty in arg
es6id: 14.4.1
author: Sam Mikes
description: GeneratorMethod uses SuperProperty (allowed)
feature: default-arg, generator, super
---*/
var obj = {
*foo(a = super.x) {
yield;
}
};
// Copyright 2015 Cubane Canada, Inc. All rights reserved.
// See LICENSE for details.
/*---
info: >
GeneratorMethod early SyntaxError when super is called
directly inside generator body
es6id: 14.4.1
author: Sam Mikes
description: GeneratorMethod error if HasDirectSuper in body
negative: SyntaxError
---*/
var obj = {
*foo(a) {
super;
}
};
// Copyright 2015 Cubane Canada, Inc. All rights reserved.
// See LICENSE for details.
/*---
info: >
GeneratorMethod can reference SuperProperty in body
es6id: 14.4.1
author: Sam Mikes
description: GeneratorMethod body uses SuperProperty (allowed)
---*/
var obj = {
*foo(a) {
yield super.x;
}
};
// Copyright 2015 Cubane Canada, Inc. All rights reserved.
// See LICENSE for details.
/*---
info: >
Generator can be declared with GeneratorMethod syntax
es6id: 14.4
author: Sam Mikes
description: can declare generator methods
---*/
var obj = {
*foo(a) { yield a+1; return; }
};
var g = obj.foo(3);
assert.sameValue(g.next().value, 4);
assert.sameValue(g.next().done, true);
// Copyright 2015 Cubane Canada, Inc. All rights reserved.
// See LICENSE for details.
/*---
info: >
GeneratorMethod early SyntaxError when lexical declaration
inside generator shadows parameter name
es6id: 14.4.1
author: Sam Mikes
description: GeneratorMethod error with lexical shadowing
negative: SyntaxError
---*/
var obj = {
*foo(a) {
const a = 3;
}
};
// Copyright 2015 Cubane Canada, Inc. All rights reserved.
// See LICENSE for details.
/*---
info: >
GeneratorMethod early SyntaxError when lexical declaration
inside generator shadows parameter name
es6id: 14.4.1
author: Sam Mikes
description: GeneratorMethod error with lexical shadowing
negative: SyntaxError
---*/
var obj = {
*foo(a) {
let a = 3;
}
};
// Copyright 2015 Cubane Canada, Inc. All rights reserved.
// See LICENSE for details.
/*---
info: >
Generator can be declared with GeneratorExpression syntax
es6id: 14.4
author: Sam Mikes
description: can create generator function expressions (no name)
---*/
var f = function *(a) { yield a+1; return; };
assert.sameValue(f.name, 'f');
var g = f(3);
assert.sameValue(g.next().value, 4);
assert.sameValue(g.next().done, true);
// Copyright 2015 Cubane Canada, Inc. All rights reserved.
// See LICENSE for details.
/*---
info: >
Generator can be declared with GeneratorExpression syntax
es6id: 14.4
author: Sam Mikes
description: can create generator function expressions (with name)
---*/
var f = function *foo(a) { yield a+1; return; };
assert.sameValue(f.name, 'foo');
var g = f(3);
assert.sameValue(g.next().value, 4);
assert.sameValue(g.next().done, true);
// Copyright 2015 Cubane Canada, Inc. All rights reserved.
// See LICENSE for details.
/*---
info: >
Generator can be declared with GeneratorExpression syntax
es6id: 14.4
author: Sam Mikes
description: can create generator function expressions (no name)
---*/
var a = [function *(a) { yield a+1; return; }];
var f = a[0];
assert.sameValue(f.name, '');
var g = f(3);
assert.sameValue(g.next().value, 4);
assert.sameValue(g.next().done, true);
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