517007283b
When printing an object literal it is often nice if each property is on its own line. This CL adds an option allowing for this. Also this is used for ObjectLiterals created by ClassBuilder. BUG= R=ahe@google.com Committed: https://code.google.com/p/dart/source/detail?r=30504 Review URL: https://codereview.chromium.org//80053004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@30565 260f80e4-7a28-3924-810f-c04153c831b5
104 lines
1.9 KiB
Dart
104 lines
1.9 KiB
Dart
// Copyright (c) 2012, 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 'dart:async';
|
|
import "package:expect/expect.dart";
|
|
import "package:async_helper/async_helper.dart";
|
|
import 'compiler_helper.dart';
|
|
import 'parser_helper.dart';
|
|
|
|
const String TEST_ONE = r"""
|
|
class A { }
|
|
class B { }
|
|
|
|
main() {
|
|
new A();
|
|
new B();
|
|
}
|
|
""";
|
|
|
|
const String TEST_TWO = r"""
|
|
class A { }
|
|
class B extends A { }
|
|
|
|
main() {
|
|
new A();
|
|
new B();
|
|
}
|
|
""";
|
|
|
|
const String TEST_THREE = r"""
|
|
class B extends A { }
|
|
class A { }
|
|
|
|
main() {
|
|
new B();
|
|
new A();
|
|
}
|
|
""";
|
|
|
|
const String TEST_FOUR = r"""
|
|
class A {
|
|
var x;
|
|
}
|
|
|
|
class B extends A {
|
|
var y;
|
|
var z;
|
|
}
|
|
|
|
main() {
|
|
new B();
|
|
}
|
|
""";
|
|
|
|
const String TEST_FIVE = r"""
|
|
class A {
|
|
var a;
|
|
A(a) : this.a = a {}
|
|
}
|
|
|
|
main() {
|
|
new A(3);
|
|
}
|
|
""";
|
|
|
|
twoClasses() {
|
|
asyncTest(() => compileAll(TEST_ONE).then((generated) {
|
|
Expect.isTrue(generated.contains(new RegExp('A: {[ \n]*"": "Object;"')));
|
|
Expect.isTrue(generated.contains(new RegExp('B: {[ \n]*"": "Object;"')));
|
|
}));
|
|
}
|
|
|
|
subClass() {
|
|
checkOutput(String generated) {
|
|
Expect.isTrue(generated.contains(new RegExp('A: {[ \n]*"": "Object;"')));
|
|
Expect.isTrue(generated.contains(new RegExp('B: {[ \n]*"": "A;"')));
|
|
}
|
|
|
|
asyncTest(() => compileAll(TEST_TWO).then(checkOutput));
|
|
asyncTest(() => compileAll(TEST_THREE).then(checkOutput));
|
|
}
|
|
|
|
fieldTest() {
|
|
asyncTest(() => compileAll(TEST_FOUR).then((generated) {
|
|
Expect.isTrue(generated.contains(
|
|
new RegExp('B: {[ \n]*"": "A;y,z,x",[ \n]*static:')));
|
|
}));
|
|
}
|
|
|
|
constructor1() {
|
|
asyncTest(() => compileAll(TEST_FIVE).then((generated) {
|
|
Expect.isTrue(generated.contains(new RegExp(r"new [$A-Z]+\.A\(a\);")));
|
|
}));
|
|
}
|
|
|
|
main() {
|
|
twoClasses();
|
|
subClass();
|
|
fieldTest();
|
|
constructor1();
|
|
}
|