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

Unified Diff: tests/compiler/dart2js/drop_trailing_null_arguments_test.dart

Issue 575013002: Drop trailing null arguments in generated JS. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix handling of Array.push Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: tests/compiler/dart2js/drop_trailing_null_arguments_test.dart
diff --git a/tests/compiler/dart2js/drop_trailing_null_arguments_test.dart b/tests/compiler/dart2js/drop_trailing_null_arguments_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..10860c6c595c2f8803f78c7b78686edafe898777
--- /dev/null
+++ b/tests/compiler/dart2js/drop_trailing_null_arguments_test.dart
@@ -0,0 +1,33 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// Test that parameters keep their names in the output.
+
+import 'package:async_helper/async_helper.dart';
+import 'package:expect/expect.dart';
+import 'compiler_helper.dart';
+
+main() {
+ // If a function call has trailing 'null' arguments, we can safely skip
+ // them as JavaScript will fill missing arguments with 'undefined'.
+ asyncTest(() => compile(r"""
+ class It<A, B> {
+ It([a, b, c]) : super;
+ }
+
+ foo(a,b,c) => a;
+ test() {
+ foo(1, null, null);
+ foo(2, 3, null);
+ new It();
+ new It(null, 1);
+ }
+ """,
+ entry: 'test', minify: false).then((String generated) {
+ print(generated);
sra1 2014/10/24 23:32:00 Remove debug print
herhut 2014/11/06 13:14:43 Done.
+ Expect.isTrue(generated.contains(r"foo(1)"));
+ Expect.isTrue(generated.contains(r"foo(2, 3)"));
+ Expect.isTrue(generated.contains(r"It$()"));
+ Expect.isTrue(generated.contains(r"It$(null, 1)"));
+ }));
+}

Powered by Google App Engine
This is Rietveld 408576698