Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(441)

Side by Side Diff: test/mjsunit/es6/destructuring.js

Issue 2229243002: Destructuring/default tests for generators and async functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add additional suggested test Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/es6/default-parameters.js ('k') | test/mjsunit/es6/generator-destructuring.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 (function TestObjectLiteralPattern() { 5 (function TestObjectLiteralPattern() {
6 var { x : x, y : y, get, set } = { x : 1, y : 2, get: 3, set: 4 }; 6 var { x : x, y : y, get, set } = { x : 1, y : 2, get: 3, set: 4 };
7 assertEquals(1, x); 7 assertEquals(1, x);
8 assertEquals(2, y); 8 assertEquals(2, y);
9 assertEquals(3, get); 9 assertEquals(3, get);
10 assertEquals(4, set); 10 assertEquals(4, set);
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 assertEquals(2, f10({x: 6}, 2)); 1038 assertEquals(2, f10({x: 6}, 2));
1039 function f11({x}, y) { var z = y; var y = 2; return z; } 1039 function f11({x}, y) { var z = y; var y = 2; return z; }
1040 assertEquals(1, f11({x: 6}, 1)); 1040 assertEquals(1, f11({x: 6}, 1));
1041 function f12(y, g = () => y) { var y = 2; return g(); } 1041 function f12(y, g = () => y) { var y = 2; return g(); }
1042 assertEquals(1, f12(1)); 1042 assertEquals(1, f12(1));
1043 function f13({x}, y, [z], v) { var x, y, z; return x*y*z*v } 1043 function f13({x}, y, [z], v) { var x, y, z; return x*y*z*v }
1044 assertEquals(210, f13({x: 2}, 3, [5], 7)); 1044 assertEquals(210, f13({x: 2}, 3, [5], 7));
1045 1045
1046 function f20({x}) { function x() { return 2 }; return x(); } 1046 function f20({x}) { function x() { return 2 }; return x(); }
1047 assertEquals(2, f20({x: 1})); 1047 assertEquals(2, f20({x: 1}));
1048 // Function hoisting is blocked by the conflicting x declaration 1048 // Annex B 3.3 function hoisting is blocked by the conflicting x declaration
1049 function f21({x}) { { function x() { return 2 } } return x(); } 1049 function f21({x}) { { function x() { return 2 } } return x; }
1050 assertThrows(() => f21({x: 1}), TypeError); 1050 assertEquals(1, f21({x: 1}));
1051 1051
1052 var g1 = ({x}) => { var x = 2; return x }; 1052 var g1 = ({x}) => { var x = 2; return x };
1053 assertEquals(2, g1({x: 1})); 1053 assertEquals(2, g1({x: 1}));
1054 var g2 = ({x}) => { { var x = 2; } return x; }; 1054 var g2 = ({x}) => { { var x = 2; } return x; };
1055 assertEquals(2, g2({x: 1})); 1055 assertEquals(2, g2({x: 1}));
1056 var g3 = ({x}) => { var y = x; var x = 2; return y; }; 1056 var g3 = ({x}) => { var y = x; var x = 2; return y; };
1057 assertEquals(1, g3({x: 1})); 1057 assertEquals(1, g3({x: 1}));
1058 var g4 = ({x}) => { { var y = x; var x = 2; } return y; }; 1058 var g4 = ({x}) => { { var y = x; var x = 2; } return y; };
1059 assertEquals(1, g4({x: 1})); 1059 assertEquals(1, g4({x: 1}));
1060 var g5 = ({x}, g = () => x) => { var x = 2; return g(); }; 1060 var g5 = ({x}, g = () => x) => { var x = 2; return g(); };
(...skipping 14 matching lines...) Expand all
1075 var g12 = (y, g = () => y) => { var y = 2; return g(); }; 1075 var g12 = (y, g = () => y) => { var y = 2; return g(); };
1076 assertEquals(1, g12(1)); 1076 assertEquals(1, g12(1));
1077 var g13 = ({x}, y, [z], v) => { var x, y, z; return x*y*z*v }; 1077 var g13 = ({x}, y, [z], v) => { var x, y, z; return x*y*z*v };
1078 assertEquals(210, g13({x: 2}, 3, [5], 7)); 1078 assertEquals(210, g13({x: 2}, 3, [5], 7));
1079 1079
1080 var g20 = ({x}) => { function x() { return 2 }; return x(); } 1080 var g20 = ({x}) => { function x() { return 2 }; return x(); }
1081 assertEquals(2, g20({x: 1})); 1081 assertEquals(2, g20({x: 1}));
1082 var g21 = ({x}) => { { function x() { return 2 } } return x(); } 1082 var g21 = ({x}) => { { function x() { return 2 } } return x(); }
1083 assertThrows(() => g21({x: 1}), TypeError); 1083 assertThrows(() => g21({x: 1}), TypeError);
1084 1084
1085 assertThrows("'use strict'; function f(x) { let x = 0; }; f({});", SyntaxError ); 1085 assertThrows("'use strict'; function f(x) { let x = 0; }", SyntaxError);
1086 assertThrows("'use strict'; function f({x}) { let x = 0; }; f({});", SyntaxErr or); 1086 assertThrows("'use strict'; function f({x}) { let x = 0; }", SyntaxError);
1087 assertThrows("'use strict'; function f(x) { const x = 0; }; f({});", SyntaxErr or); 1087 assertThrows("'use strict'; function f(x) { const x = 0; }", SyntaxError);
1088 assertThrows("'use strict'; function f({x}) { const x = 0; }; f({});", SyntaxE rror); 1088 assertThrows("'use strict'; function f({x}) { const x = 0; }", SyntaxError);
1089 1089
1090 assertThrows("'use strict'; let g = (x) => { let x = 0; }; f({});", SyntaxErro r); 1090 assertThrows("'use strict'; let g = (x) => { let x = 0; }", SyntaxError);
1091 assertThrows("'use strict'; let g = ({x}) => { let x = 0; }; f({});", SyntaxEr ror); 1091 assertThrows("'use strict'; let g = ({x}) => { let x = 0; }", SyntaxError);
1092 assertThrows("'use strict'; let g = (x) => { const x = 0; }; f({});", SyntaxEr ror); 1092 assertThrows("'use strict'; let g = (x) => { const x = 0; }", SyntaxError);
1093 assertThrows("'use strict'; let g = ({x}) => { const x = 0; }; f({});", Syntax Error); 1093 assertThrows("'use strict'; let g = ({x}) => { const x = 0; }", SyntaxError);
1094 }()); 1094 }());
1095 1095
1096 1096
1097 (function TestArgumentsForNonSimpleParameters() { 1097 (function TestArgumentsForNonSimpleParameters() {
1098 function f1({}, x) { arguments[1] = 0; return x } 1098 function f1({}, x) { arguments[1] = 0; return x }
1099 assertEquals(6, f1({}, 6)); 1099 assertEquals(6, f1({}, 6));
1100 function f2({}, x) { x = 2; return arguments[1] } 1100 function f2({}, x) { x = 2; return arguments[1] }
1101 assertEquals(7, f2({}, 7)); 1101 assertEquals(7, f2({}, 7));
1102 function f3(x, {}) { arguments[0] = 0; return x } 1102 function f3(x, {}) { arguments[0] = 0; return x }
1103 assertEquals(6, f3(6, {})); 1103 assertEquals(6, f3(6, {}));
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 assertEquals([2, 3], bar); 1182 assertEquals([2, 3], bar);
1183 } 1183 }
1184 1184
1185 assertEquals("hello", foo); 1185 assertEquals("hello", foo);
1186 assertEquals("world", bar); 1186 assertEquals("world", bar);
1187 assertEquals(42, baz); 1187 assertEquals(42, baz);
1188 1188
1189 assertEquals(undefined, eval('try {throw {foo: 1, bar: 2}} catch({foo}) {}')); 1189 assertEquals(undefined, eval('try {throw {foo: 1, bar: 2}} catch({foo}) {}'));
1190 assertEquals(undefined, eval('try {throw [1, 2, 3]} catch([x]) {}')); 1190 assertEquals(undefined, eval('try {throw [1, 2, 3]} catch([x]) {}'));
1191 })(); 1191 })();
OLDNEW
« no previous file with comments | « test/mjsunit/es6/default-parameters.js ('k') | test/mjsunit/es6/generator-destructuring.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698