| Index: test/mjsunit/harmony/optional-arguments.js | 
| diff --git a/test/mjsunit/harmony/optional-arguments.js b/test/mjsunit/harmony/optional-arguments.js | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..d0fe0bbe239c5a3472d51a38004478d7c55f68b3 | 
| --- /dev/null | 
| +++ b/test/mjsunit/harmony/optional-arguments.js | 
| @@ -0,0 +1,67 @@ | 
| +// Copyright 2015 the V8 project authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| + | 
| +function return_specified() { return "specified"; } | 
| + | 
| +var method_returns_specified = { | 
| +  method() { return "specified"; } | 
| +}; | 
| + | 
| + | 
| +(function testOptionalFunctions() { | 
| +  function optional_function(handler = function() { }) { | 
| +    assertEquals("function", typeof handler); | 
| + | 
| +    // TODO(caitp): infer function name correctly | 
| +    // assertEquals("handler", handler.name); | 
| + | 
| +    return handler(); | 
| +  } | 
| +  assertEquals(undefined, optional_function()); | 
| +  assertEquals(undefined, optional_function(undefined)); | 
| +  assertEquals("specified", optional_function(return_specified)); | 
| +})(); | 
| + | 
| + | 
| +(function testOptionalObjects() { | 
| +  function optional_object(object = { method() { return "method"; } }) { | 
| +    assertEquals("object", typeof object); | 
| + | 
| +    assertEquals("function", typeof object.method); | 
| +    return object.method(); | 
| +  } | 
| + | 
| +  assertEquals("method", optional_object()); | 
| +  assertEquals("method", optional_object(undefined)); | 
| +  assertEquals("specified", optional_object(method_returns_specified)); | 
| +})(); | 
| + | 
| + | 
| +// TDZ | 
| + | 
| +(function testReferencesUninitializedParameter(x = 1) { | 
| +  assertThrows(function(a = b, b) {}, ReferenceError); | 
| +})(); | 
| + | 
| + | 
| +(function testReferencesInitializedParameter(x = 1) { | 
| +  assertEquals(1, (function(a = 1, b = a) { return b; })()); | 
| +})(); | 
| + | 
| + | 
| +// Scoping | 
| +assertThrows(function referencesVariableBodyDeclaration(a = body_var) { | 
| +  var body_var = true; | 
| +  return a; | 
| +}, ReferenceError); | 
| + | 
| + | 
| +// TODO(caitp): default function length does not include any parameters | 
| +// following the first optional parameter | 
| +// assertEquals(0, (function(a = 1) {}).length); | 
| +// assertEquals(1, (function(a, b = 1) {}).length); | 
| +// assertEquals(2, (function(a, b, c = 1) {}).length); | 
| +// assertEquals(3, (function(a, b, c, d = 1) {}).length); | 
| +// assertEquals(1, (function(a, b = 1, c, d = 1) {}).length); | 
|  |