saambarati1@gmail.com | a037668 | 2015-02-10 07:40:53 +0000 | [diff] [blame] | 1 | load("./driver/driver.js"); |
| 2 | |
| 3 | function testForIn(x) { |
saambarati1@gmail.com | 784581f | 2015-02-10 19:01:41 +0000 | [diff] [blame] | 4 | for (var arg1 in x) |
| 5 | x; |
| 6 | |
saambarati1@gmail.com | a037668 | 2015-02-10 07:40:53 +0000 | [diff] [blame] | 7 | for (arg2 in x) |
| 8 | x; |
| 9 | |
saambarati1@gmail.com | 784581f | 2015-02-10 19:01:41 +0000 | [diff] [blame] | 10 | for ({x: arg3} in x) |
| 11 | x; |
| 12 | |
| 13 | for (var {x: arg4} in x) |
saambarati1@gmail.com | a037668 | 2015-02-10 07:40:53 +0000 | [diff] [blame] | 14 | x; |
| 15 | } |
| 16 | |
| 17 | function testForOf(x) { |
saambarati1@gmail.com | 784581f | 2015-02-10 19:01:41 +0000 | [diff] [blame] | 18 | for (var arg1 of x) |
| 19 | x; |
| 20 | |
saambarati1@gmail.com | a037668 | 2015-02-10 07:40:53 +0000 | [diff] [blame] | 21 | for (arg2 of x) |
| 22 | x; |
| 23 | |
| 24 | for ({x: arg3} of x) |
| 25 | x; |
saambarati1@gmail.com | 784581f | 2015-02-10 19:01:41 +0000 | [diff] [blame] | 26 | for (var {x: arg4} of x) |
| 27 | x; |
saambarati1@gmail.com | a037668 | 2015-02-10 07:40:53 +0000 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | testForIn([1]) |
saambarati1@gmail.com | 784581f | 2015-02-10 19:01:41 +0000 | [diff] [blame] | 31 | var types = findTypeForExpression(testForIn, "arg1"); |
| 32 | assert(types.instructionTypeSet.primitiveTypeNames.indexOf(T.String) !== -1, "Primitive type names should contain 'String'"); |
| 33 | types = findTypeForExpression(testForIn, "arg2"); |
saambarati1@gmail.com | a037668 | 2015-02-10 07:40:53 +0000 | [diff] [blame] | 34 | assert(types.instructionTypeSet.primitiveTypeNames.indexOf(T.String) !== -1, "Primitive type names should contain 'String'"); |
| 35 | types = findTypeForExpression(testForIn, "arg3"); |
| 36 | assert(types.instructionTypeSet.primitiveTypeNames.indexOf(T.Undefined) !== -1, "Primitive type names should contain 'Undefined'"); |
saambarati1@gmail.com | 784581f | 2015-02-10 19:01:41 +0000 | [diff] [blame] | 37 | types = findTypeForExpression(testForIn, "arg4"); |
| 38 | assert(types.instructionTypeSet.primitiveTypeNames.indexOf(T.Undefined) !== -1, "Primitive type names should contain 'Undefined'"); |
saambarati1@gmail.com | a037668 | 2015-02-10 07:40:53 +0000 | [diff] [blame] | 39 | |
| 40 | testForOf([1]) |
saambarati1@gmail.com | 784581f | 2015-02-10 19:01:41 +0000 | [diff] [blame] | 41 | types = findTypeForExpression(testForOf, "arg1"); |
| 42 | assert(types.instructionTypeSet.primitiveTypeNames.indexOf(T.Integer) !== -1, "Primitive type names should contain 'Integer'"); |
saambarati1@gmail.com | a037668 | 2015-02-10 07:40:53 +0000 | [diff] [blame] | 43 | types = findTypeForExpression(testForOf, "arg2"); |
| 44 | assert(types.instructionTypeSet.primitiveTypeNames.indexOf(T.Integer) !== -1, "Primitive type names should contain 'Integer'"); |
| 45 | types = findTypeForExpression(testForOf, "arg3"); |
| 46 | assert(types.instructionTypeSet.primitiveTypeNames.indexOf(T.Undefined) !== -1, "Primitive type names should contain 'Undefined'"); |
saambarati1@gmail.com | 784581f | 2015-02-10 19:01:41 +0000 | [diff] [blame] | 47 | types = findTypeForExpression(testForOf, "arg4"); |
| 48 | assert(types.instructionTypeSet.primitiveTypeNames.indexOf(T.Undefined) !== -1, "Primitive type names should contain 'Undefined'"); |
saambarati1@gmail.com | a037668 | 2015-02-10 07:40:53 +0000 | [diff] [blame] | 49 | testForOf([{x:29}]) |
saambarati1@gmail.com | 784581f | 2015-02-10 19:01:41 +0000 | [diff] [blame] | 50 | types = findTypeForExpression(testForOf, "arg1"); |
saambarati1@gmail.com | a037668 | 2015-02-10 07:40:53 +0000 | [diff] [blame] | 51 | assert(types.instructionTypeSet.structures[0].fields.indexOf("x") !== -1, "variable 'arg1' should have field 'x'"); |
saambarati1@gmail.com | 784581f | 2015-02-10 19:01:41 +0000 | [diff] [blame] | 52 | types = findTypeForExpression(testForOf, "arg2"); |
| 53 | assert(types.instructionTypeSet.structures[0].fields.indexOf("x") !== -1, "variable 'arg2' should have field 'x'"); |
saambarati1@gmail.com | a037668 | 2015-02-10 07:40:53 +0000 | [diff] [blame] | 54 | types = findTypeForExpression(testForOf, "arg3"); |
| 55 | assert(types.instructionTypeSet.primitiveTypeNames.indexOf(T.Integer) !== -1, "Primitive type names should contain 'Integer'"); |
saambarati1@gmail.com | 784581f | 2015-02-10 19:01:41 +0000 | [diff] [blame] | 56 | types = findTypeForExpression(testForOf, "arg4"); |
| 57 | assert(types.instructionTypeSet.primitiveTypeNames.indexOf(T.Integer) !== -1, "Primitive type names should contain 'Integer'"); |