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

Side by Side Diff: tests/compiler/dart2js/use_strict_test.dart

Issue 929503004: dart2js: Don't emit fields that are named "eval" or "arguments". (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « pkg/compiler/lib/src/js_backend/namer.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'dart:async';
6
7 import 'package:async_helper/async_helper.dart';
8 import 'package:expect/expect.dart';
9 import 'memory_compiler.dart';
10
11 // Use strict does not allow parameters or locals named "arguments" or "eval".
12
13 const MEMORY_SOURCE_FILES = const {
14 'main.dart': '''
15 class A {
16 final arguments;
17 final eval;
18 A(this.arguments, this.eval);
19
20 foo(x, y) => this.arguments + this.eval;
21 }
22
23 class B {
24 foo(arguments, eval) => arguments + eval;
25 }
26
27 class C {
28 foo(var x, var y) {
29 var arguments, eval;
30 arguments = x + y;
31 eval = x - y;
32 if (arguments < eval) return arguments;
33 return eval;
34 }
35 }
36
37 main() {
38 var list = [];
39 for (int i = 0; i < 1000; i++) {
40 list.add(new A(i, i + 1));
41 list.add(new B());
42 list.add(new C());
43 }
44 for (int i = 0; i < list.length; i++) {
45 print(list[i].foo(i, i + 1));
46 }
47 }'''};
48
49 main() {
50 OutputCollector collector = new OutputCollector();
51 var compiler = compilerFor(MEMORY_SOURCE_FILES, outputProvider: collector);
52 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) {
53 String jsOutput = collector.getOutput('', 'js');
54
55 // Skip comments.
56 List<String> lines = jsOutput.split("\n");
57 RegExp commentLine = new RegExp(r' *//');
58 String filtered = lines
59 .where((String line) => !commentLine.hasMatch(line))
60 .join("\n");
61
62 // TODO(floitsch): we will need to adjust this filter if we start using
63 // 'eval' or 'arguments' ourselves. Currently we disallow any 'eval' or
64 // 'arguments'.
65 RegExp re = new RegExp(r'[^\w$](arguments|eval)[^\w$]');
66 Expect.isFalse(re.hasMatch(filtered));
67 }));
68 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/namer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698