diff --git a/tests/README b/tests/README new file mode 100644 index 00000000000..a9e3bb62beb --- /dev/null +++ b/tests/README @@ -0,0 +1,43 @@ +Run Existing Tests +================== + +See the output of + + ../tools/test.py --help + +for how to run tests. + +See also + + https://code.google.com/p/dart/wiki/Building#Testing + +for detailed examples. + +Create New Tests +================ + +See comments above + + factory StandardTestSuite.forDirectory + +in + + ../tools/testing/dart/test_suite.dart + +for the default test directory layout. By default test-file names must +end in "_test.dart", but some test suites, such as ./co19, subclass +StandardTestSuite and override this default. + +See comments at the beginning of + + ../tools/testing/dart/multitest.dart + +for how to create tests that pass by failing with a known error. For +example, + + ... + int x = "not an int"; /// 01: static type warning + ... + +as part of a test will only pass the "--compiler dartanalyzer" test if +the assignment generates a static type warning. diff --git a/tests/language/issue18628_1_test.dart b/tests/language/issue18628_1_test.dart new file mode 100644 index 00000000000..9481efde144 --- /dev/null +++ b/tests/language/issue18628_1_test.dart @@ -0,0 +1,20 @@ +// 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. + +// This test checks for a regression found in Dart Editor: the +// analyzer was treating [Type] as more specific than any type +// variable (generic parameter). +// +// https://code.google.com/p/dart/issues/detail?id=18628 + +class C { + // This line is supposed to cause the warning; the other commented + // line just doesn't make sense without this line. + T t = int; /// 01: static type warning +} + +main() { + C c = new C(); + print(c.t); /// 01: static type warning +} diff --git a/tests/language/issue18628_2_test.dart b/tests/language/issue18628_2_test.dart new file mode 100644 index 00000000000..a6e1cfd73e4 --- /dev/null +++ b/tests/language/issue18628_2_test.dart @@ -0,0 +1,20 @@ +// 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. + +// This test checks for a regression found in Dart Editor: the +// analyzer was treating [Type] as more specific than any type +// variable (generic parameter). +// +// https://code.google.com/p/dart/issues/detail?id=18628 + +class X {} + +// This line is supposed to cause the warning; the other lines are +// marked because they don't make sense when [Y] is not defined. +class Y extends X {} /// 01: static type warning + +main() { + X x = new X(); /// 01: static type warning + Y y = new Y(); /// 01: static type warning +} diff --git a/tools/test.dart b/tools/test.dart index 89b9d728d07..880dd007b70 100755 --- a/tools/test.dart +++ b/tools/test.dart @@ -18,8 +18,12 @@ * and passses along all command line arguments to this script.) * * The command line args of this script are documented in - * "tools/testing/test_options.dart". + * "tools/testing/dart/test_options.dart"; they are printed + * when this script is run with "--help". * + * The default test directory layout is documented in + * "tools/testing/dart/test_suite.dart", above + * "factory StandardTestSuite.forDirectory". */ library test; diff --git a/tools/testing/dart/test_options.dart b/tools/testing/dart/test_options.dart index f5259d7e963..ad4cccf1a47 100644 --- a/tools/testing/dart/test_options.dart +++ b/tools/testing/dart/test_options.dart @@ -823,7 +823,13 @@ Note: currently only implemented for dart2js.''', * Print out usage information. */ void _printHelp() { - print('usage: dart test.dart [options]\n'); + print('usage: dart test.dart [options] [selector]'); + print(''); + print('The optional selector limits the tests that will be run.'); + print('For example, the selector "language/issue", or equivalently'); + print('"language/*issue*", limits to test files matching the regexp'); + print('".*issue.*\\.dart" in the "tests/language" directory.'); + print(''); print('Options:\n'); for (var option in _options) { print('${option.name}: ${option.description}.');