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

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

Issue 338053002: Version 1.4.3. (Closed) Base URL: http://dart.googlecode.com/svn/branches/1.4/
Patch Set: Created 6 years, 6 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
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/inferrer/type_graph_nodes.dart ('k') | dart/tools/VERSION » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/tests/compiler/dart2js/dictionary_types_test.dart
===================================================================
--- dart/tests/compiler/dart2js/dictionary_types_test.dart (revision 37347)
+++ dart/tests/compiler/dart2js/dictionary_types_test.dart (working copy)
@@ -8,7 +8,7 @@
import 'compiler_helper.dart' show findElement;
var SOURCES = const {
-'testAddAll.dart': """
+'AddAll.dart': """
var dictionaryA = {'string': "aString", 'int': 42, 'double': 21.5,
'list': []};
var dictionaryB = {'string': "aString", 'int': 42, 'double': 21.5,
@@ -28,7 +28,7 @@
nullOrInt = dictionaryB['intTwo'];
}
""",
-'testUnion.dart': """
+'Union.dart': """
var dictionaryA = {'string': "aString", 'int': 42, 'double': 21.5,
'list': []};
var dictionaryB = {'string': "aString", 'intTwo': 42, 'list': []};
@@ -44,7 +44,7 @@
doubleOrNull = union['double'];
}
""",
-'testValueType.dart': """
+'ValueType.dart': """
var dictionary = {'string': "aString", 'int': 42, 'double': 21.5, 'list': []};
var keyD = 'double';
var keyI = 'int';
@@ -58,7 +58,7 @@
var x = [intOrNull, justNull];
}
""",
-'testPropagation.dart': """
+'Propagation.dart': """
class A {
A();
foo(value) {
@@ -83,28 +83,52 @@
}
print(it.foo(dictionary) + 2);
}
+""",
+'Bailout.dart': """
+ var dict = makeMap([1,2]);
+ var notInt = 0;
+ var alsoNotInt = 0;
+
+ makeMap(values) {
+ return {'moo': values[0], 'boo': values[1]};
+ }
+
+ main () {
+ dict['goo'] = 42;
+ var closure = dictfun() => dict;
+ notInt = closure()['boo'];
+ alsoNotInt = dict['goo'];
+ print("\$notInt and \$alsoNotInt.");
+ }
"""};
void main() {
asyncTest(() =>
- compileAndTest("testAddAll.dart", (types, getType, compiler) {
+ compileAndTest("AddAll.dart", (types, getType, compiler) {
Expect.equals(getType('int'), types.uint31Type);
Expect.equals(getType('anotherInt'), types.uint31Type);
Expect.equals(getType('dynamic'), types.dynamicType);
Expect.equals(getType('nullOrInt'), types.uint31Type.nullable());
- }).then((_) => compileAndTest("testUnion.dart", (types, getType, compiler) {
- Expect.equals(getType('nullOrInt'), types.uint31Type.nullable());
- Expect.isTrue(getType('aString').containsOnlyString(compiler));
- Expect.equals(getType('doubleOrNull'), types.doubleType.nullable());
- })).then((_) => compileAndTest("testValueType.dart",
- (types, getType, compiler) {
+ }));
+ asyncTest(() => compileAndTest("Union.dart", (types, getType, compiler) {
+ Expect.equals(getType('nullOrInt'), types.uint31Type.nullable());
+ Expect.isTrue(getType('aString').containsOnlyString(compiler));
+ Expect.equals(getType('doubleOrNull'), types.doubleType.nullable());
+ }));
+ asyncTest(() =>
+ compileAndTest("ValueType.dart", (types, getType, compiler) {
Expect.equals(getType('knownDouble'), types.doubleType);
Expect.equals(getType('intOrNull'), types.uint31Type.nullable());
Expect.equals(getType('justNull'), types.nullType);
- })).then((_) => compileAndTest("testPropagation.dart", (code) {
- Expect.isFalse(code.contains("J.\$add\$ns"));
- }, createCode: true))
- );
+ }));
+ asyncTest(() => compileAndTest("Propagation.dart", (code) {
+ Expect.isFalse(code.contains("J.\$add\$ns"));
+ }, createCode: true));
+ asyncTest(() => compileAndTest("Bailout.dart", (types, getType, compiler) {
+ Expect.equals(getType('notInt'), types.dynamicType);
+ Expect.equals(getType('alsoNotInt'), types.dynamicType);
+ Expect.isFalse(getType('dict').isDictionary);
+ }));
}
compileAndTest(source, checker, {createCode: false}) {
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/inferrer/type_graph_nodes.dart ('k') | dart/tools/VERSION » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698