OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --harmony-types |
| 6 |
| 7 |
| 8 load("test/mjsunit/harmony/typesystem/typegen.js"); |
| 9 |
| 10 |
| 11 // In all the following functions, the size parameter (positive integer) |
| 12 // denotes how many test cases will be tried. The variable test_size |
| 13 // controls execution time of this test. It should not be too high. |
| 14 let test_size = 1000; |
| 15 |
| 16 |
| 17 function ValidTypeAliases(size) { |
| 18 return Generate(size, [ |
| 19 new TestGen(1, ValidTypes, [ |
| 20 t => "type T = " + t, |
| 21 t => "type T<A> = " + t, |
| 22 t => "type T<A, B> = " + t, |
| 23 t => "type T<A extends {x: number}, B> = " + t |
| 24 ]) |
| 25 ]); |
| 26 } |
| 27 |
| 28 function InvalidTypeAliases(size) { |
| 29 return Generate(size, [ |
| 30 new TestGen(1, InvalidTypes, [ |
| 31 t => "type T = " + t, |
| 32 t => "type T<A> = " + t, |
| 33 t => "type T<A, B> = " + t, |
| 34 t => "type T<A extends {x: number}, B> = " + t |
| 35 ]), |
| 36 "type T<> = number", |
| 37 "type T", |
| 38 "type T =" |
| 39 ]); |
| 40 } |
| 41 |
| 42 (function TestTypeAliases(size) { |
| 43 Test(size, [ |
| 44 new TestGen(3, ValidTypeAliases, [CheckValid]), |
| 45 new TestGen(1, InvalidTypeAliases, [CheckInvalid]), |
| 46 ]); |
| 47 CheckValid("var type; type"); |
| 48 CheckValid("var type, number=10; type = number+1"); |
| 49 CheckValid("function type() {}; type(1, 2, 3)"); |
| 50 CheckValid("var type; type\n42"); |
| 51 })(test_size); |
OLD | NEW |