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

Side by Side Diff: frog/tests/leg/src/ResolverTest.dart

Issue 8924001: First implementation of top-level fields without initializers. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #import("../../../leg/leg.dart"); 5 #import("../../../leg/leg.dart");
6 #import("../../../leg/elements/elements.dart"); 6 #import("../../../leg/elements/elements.dart");
7 #import("../../../leg/tree/tree.dart"); 7 #import("../../../leg/tree/tree.dart");
8 #import("../../../leg/util/util.dart"); 8 #import("../../../leg/util/util.dart");
9 #import("mock_compiler.dart"); 9 #import("mock_compiler.dart");
10 #import("parser_helper.dart"); 10 #import("parser_helper.dart");
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 testLocalsFive(); 56 testLocalsFive();
57 testParametersOne(); 57 testParametersOne();
58 testFor(); 58 testFor();
59 testTypeAnnotation(); 59 testTypeAnnotation();
60 testSuperclass(); 60 testSuperclass();
61 // testVarSuperclass(); // The parser crashes with 'class Foo extends var'. 61 // testVarSuperclass(); // The parser crashes with 'class Foo extends var'.
62 // testOneInterface(); // The parser does not handle interfaces. 62 // testOneInterface(); // The parser does not handle interfaces.
63 // testTwoInterfaces(); // The parser does not handle interfaces. 63 // testTwoInterfaces(); // The parser does not handle interfaces.
64 testFunctionExpression(); 64 testFunctionExpression();
65 testNewExpression(); 65 testNewExpression();
66 testTopLevelFields();
66 } 67 }
67 68
68 testLocalsOne() { 69 testLocalsOne() {
69 testLocals([["foo", false]]); 70 testLocals([["foo", false]]);
70 testLocals([["foo", false], ["bar", false]]); 71 testLocals([["foo", false], ["bar", false]]);
71 testLocals([["foo", false], ["bar", false], ["foobar", false]]); 72 testLocals([["foo", false], ["bar", false], ["foobar", false]]);
72 73
73 testLocals([["foo", true]]); 74 testLocals([["foo", true]]);
74 testLocals([["foo", false], ["bar", true]]); 75 testLocals([["foo", false], ["bar", true]]);
75 testLocals([["foo", true], ["bar", true]]); 76 testLocals([["foo", true], ["bar", true]]);
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 346
346 fooElement.parseNode(compiler, compiler); 347 fooElement.parseNode(compiler, compiler);
347 compiler.resolver.resolve(fooElement); 348 compiler.resolver.resolve(fooElement);
348 349
349 TreeElements elements = compiler.resolveStatement("new A();"); 350 TreeElements elements = compiler.resolveStatement("new A();");
350 Element element = 351 Element element =
351 elements[compiler.parsedTree.asExpressionStatement().expression.send]; 352 elements[compiler.parsedTree.asExpressionStatement().expression.send];
352 Expect.equals(ElementKind.CONSTRUCTOR, element.kind); 353 Expect.equals(ElementKind.CONSTRUCTOR, element.kind);
353 Expect.isTrue(element is SynthesizedConstructorElement); 354 Expect.isTrue(element is SynthesizedConstructorElement);
354 } 355 }
356
357 testTopLevelFields() {
358 MockCompiler compiler = new MockCompiler();
359 compiler.parseScript("int a;");
360 Element element = compiler.universe.find(buildSourceString("a"));
361 Expect.equals(ElementKind.FIELD, element.kind);
362 Node node = element.parseNode(compiler, compiler);
363 Expect.equals(node.type.typeName.source.stringValue, 'int');
364
365 compiler.parseScript("var b, c;");
366 Element bElement = compiler.universe.find(buildSourceString("b"));
367 Element cElement = compiler.universe.find(buildSourceString("c"));
368 Expect.equals(ElementKind.FIELD, bElement.kind);
369 Expect.equals(ElementKind.FIELD, cElement.kind);
370 Expect.isTrue(bElement != cElement);
371
372 Node bNode = bElement.parseNode(compiler, compiler);
373 Node cNode = cElement.parseNode(compiler, compiler);
374 Expect.equals(bNode, cNode);
375 Expect.equals(bNode.type.typeName.source.stringValue, 'var');
376 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698