File tree Expand file tree Collapse file tree 2 files changed +83
-0
lines changed
tests/cases/conformance/es6/yieldExpressions Expand file tree Collapse file tree 2 files changed +83
-0
lines changed Original file line number Diff line number Diff line change
1
+ // @module : commonjs
2
+ // @target : es6
3
+ // @noImplicitAny : true
4
+
5
+ export interface StrategicState {
6
+ lastStrategyApplied ?: string ;
7
+ }
8
+
9
+ export function strategy < T extends StrategicState > ( stratName : string , gen : ( a : T ) => IterableIterator < T | undefined > ) : ( a : T ) => IterableIterator < T | undefined > {
10
+ return function * ( state ) {
11
+ for ( const next of gen ( state ) ) {
12
+ if ( next ) {
13
+ next . lastStrategyApplied = stratName ;
14
+ }
15
+ yield next ;
16
+ }
17
+ }
18
+ }
19
+
20
+ export interface Strategy < T > {
21
+ ( a : T ) : IterableIterator < T | undefined > ;
22
+ }
23
+
24
+ export interface State extends StrategicState {
25
+ foo : number ;
26
+ }
27
+
28
+ export const Nothing1 : Strategy < State > = strategy ( "Nothing" , function * ( state : State ) {
29
+ return state ;
30
+ } ) ;
31
+
32
+ export const Nothing2 : Strategy < State > = strategy ( "Nothing" , function * ( state : State ) {
33
+ yield state ;
34
+ } ) ;
35
+
36
+ export const Nothing3 : Strategy < State > = strategy ( "Nothing" , function * ( state : State ) {
37
+ yield ;
38
+ return state ;
39
+ } ) ;
40
+
Original file line number Diff line number Diff line change
1
+ // @module : commonjs
2
+ // @target : es6
3
+ // @noImplicitAny : true
4
+
5
+ export interface StrategicState {
6
+ lastStrategyApplied ?: string ;
7
+ }
8
+
9
+ export function strategy < T extends StrategicState > ( stratName : string , gen : ( a : T ) => IterableIterator < T | undefined > ) : ( a : T ) => IterableIterator < T | undefined > {
10
+ return function * ( state ) {
11
+ for ( const next of gen ( state ) ) {
12
+ if ( next ) {
13
+ next . lastStrategyApplied = stratName ;
14
+ }
15
+ yield next ;
16
+ }
17
+ }
18
+ }
19
+
20
+ export interface Strategy < T > {
21
+ ( a : T ) : IterableIterator < T | undefined > ;
22
+ }
23
+
24
+ export interface State extends StrategicState {
25
+ foo : number ;
26
+ }
27
+
28
+ export const Nothing : Strategy < State > = strategy ( "Nothing" , function * ( state : State ) {
29
+ yield 1 ;
30
+ return state ;
31
+ } ) ;
32
+
33
+ export const Nothing1 : Strategy < State > = strategy ( "Nothing" , function * ( state : State ) {
34
+ } ) ;
35
+
36
+ export const Nothing2 : Strategy < State > = strategy ( "Nothing" , function * ( state : State ) {
37
+ return 1 ;
38
+ } ) ;
39
+
40
+ export const Nothing3 : Strategy < State > = strategy ( "Nothing" , function * ( state : State ) {
41
+ yield state ;
42
+ return 1 ;
43
+ } ) ;
You can’t perform that action at this time.
0 commit comments