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 var debug = false; | 5 var debug = false; |
6 | 6 |
7 function CheckValid(type) { | 7 function CheckValid(script) { |
8 if (debug) { print("V:", type); } | 8 if (debug) { print("V:", script); } |
9 assertDoesNotThrow("'use types'; var x: " + type + ";"); | 9 assertDoesNotThrow("'use types'; " + script); |
10 } | 10 } |
11 | 11 |
12 function CheckInvalid(type) { | 12 function CheckInvalid(script, exception=SyntaxError) { |
13 if (debug) { print("I:", type); } | 13 if (debug) { print("I:", script); } |
14 assertThrows("'use types'; var x: " + type + ";", SyntaxError); | 14 assertThrows("'use types'; " + script, exception); |
| 15 } |
| 16 |
| 17 function CheckValidType(type) { |
| 18 CheckValid("var x: " + type + ";"); |
| 19 } |
| 20 |
| 21 function CheckInvalidType(type, exception=SyntaxError) { |
| 22 CheckInvalid("var x: " + type + ";", exception); |
15 } | 23 } |
16 | 24 |
17 // Parameters: | 25 // Parameters: |
18 // multiplicity: positive integer | 26 // multiplicity: positive integer |
19 // generator: (size: positive integer, ...params: any[]) => Iterator<SomeType> | 27 // generator: (size: positive integer, ...params: any[]) => Iterator<SomeType> |
20 // transformations: [false | ((t: SomeType) => OtherType)] | 28 // transformations: [false | ((t: SomeType) => OtherType)] |
21 // params: any[] | 29 // params: any[] |
22 // | 30 // |
23 // A "test generator" object will have its "generator" generate tests, | 31 // A "test generator" object will have its "generator" generate tests, |
24 // will transform each generated test with all of its "transformations" | 32 // will transform each generated test with all of its "transformations" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 } | 116 } |
109 } | 117 } |
110 } | 118 } |
111 | 119 |
112 // Parameters: | 120 // Parameters: |
113 // size: positive integer | 121 // size: positive integer |
114 // generators: [string | TestGen] | 122 // generators: [string | TestGen] |
115 // | 123 // |
116 // This function will generate all tests yielded by Generate and will | 124 // This function will generate all tests yielded by Generate and will |
117 // discard the results. It will normally be called with test generators | 125 // discard the results. It will normally be called with test generators |
118 // whose transformation functions test for validity (e.g. CheckValid or | 126 // whose transformation functions test for validity (e.g. CheckValidType |
119 // CheckInvalid) and do not return anything interesting. | 127 // or CheckInvalidType) and do not return anything interesting. |
120 function Test(size, generators) { | 128 function Test(size, generators) { |
121 for (let attempt of Generate(size, generators)) continue; | 129 for (let attempt of Generate(size, generators)) continue; |
122 } | 130 } |
OLD | NEW |