| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Flags: --harmony-function-sent | 5 // Flags: --harmony-function-sent |
| 6 | 6 |
| 7 | 7 |
| 8 { | 8 { |
| 9 function* g() { return function.sent } | 9 function* g() { return function.sent } |
| 10 assertEquals({value: 42, done: true}, g().next(42)); | 10 assertEquals({value: 42, done: true}, g().next(42)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 assertEquals({value: 3, done: true}, x.next(3)); | 42 assertEquals({value: 3, done: true}, x.next(3)); |
| 43 } | 43 } |
| 44 } | 44 } |
| 45 | 45 |
| 46 | 46 |
| 47 { | 47 { |
| 48 function* inner() { | 48 function* inner() { |
| 49 try { | 49 try { |
| 50 yield function.sent; | 50 yield function.sent; |
| 51 } finally { | 51 } finally { |
| 52 return 666; | 52 return 23; |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 | 55 |
| 56 function* g() { | 56 function* g() { |
| 57 yield function.sent; | 57 yield function.sent; |
| 58 yield* inner(); | 58 yield* inner(); |
| 59 return function.sent; | 59 return function.sent; |
| 60 } | 60 } |
| 61 | 61 |
| 62 { | 62 { |
| 63 let x = g(); | 63 let x = g(); |
| 64 assertEquals({value: 1, done: false}, x.next(1)); | 64 assertEquals({value: 1, done: false}, x.next(1)); |
| 65 assertEquals({value: undefined, done: false}, x.next(2)); | 65 assertEquals({value: undefined, done: false}, x.next(2)); |
| 66 assertEquals({value: 3, done: true}, x.next(3)); | 66 assertEquals({value: 3, done: true}, x.next(3)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 { | 69 { |
| 70 let x = g(); | 70 let x = g(); |
| 71 assertEquals({value: 1, done: false}, x.next(1)); | 71 assertEquals({value: 1, done: false}, x.next(1)); |
| 72 assertEquals({value: undefined, done: false}, x.next(2)); | 72 assertEquals({value: undefined, done: false}, x.next(2)); |
| 73 assertEquals({value: 42, done: true}, x.throw(42)); | 73 assertEquals({value: 42, done: true}, x.throw(42)); |
| 74 } | 74 } |
| 75 | 75 |
| 76 { | 76 { |
| 77 let x = g(); | 77 let x = g(); |
| 78 assertEquals({value: 1, done: false}, x.next(1)); | 78 assertEquals({value: 1, done: false}, x.next(1)); |
| 79 assertEquals({value: undefined, done: false}, x.next(2)); | 79 assertEquals({value: undefined, done: false}, x.next(2)); |
| 80 assertEquals({value: 42, done: true}, x.return(42)); | 80 assertEquals({value: 23, done: true}, x.return(42)); |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 | 83 |
| 84 | 84 |
| 85 assertThrows("function f() { return function.sent }", SyntaxError); | 85 assertThrows("function f() { return function.sent }", SyntaxError); |
| 86 assertThrows("() => { return function.sent }", SyntaxError); | 86 assertThrows("() => { return function.sent }", SyntaxError); |
| 87 assertThrows("() => { function.sent }", SyntaxError); | 87 assertThrows("() => { function.sent }", SyntaxError); |
| 88 assertThrows("() => function.sent", SyntaxError); | 88 assertThrows("() => function.sent", SyntaxError); |
| 89 assertThrows("({*f() { function.sent }})", SyntaxError); | 89 assertThrows("({*f() { function.sent }})", SyntaxError); |
| 90 assertDoesNotThrow("({*f() { return function.sent }})"); | 90 assertDoesNotThrow("({*f() { return function.sent }})"); |
| OLD | NEW |