mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 14:59:41 +00:00
Add language tests for Issue 18628.
As suggested by @karlklose in https://codereview.chromium.org/513563002/ comments. Improve testing documentation. - add a README - add a description by example of selectors to the "./tools/test.py -h" output - update/add source comments I had a hard time figuring out how to add and run the tests, mostly because I tried to call them "*_test_1.dart" and "*_test_2.dart", but language test files must have names of the form "*_test.dart". So, I added a README summarizing and referencing the relevant docs. R=brianwilkerson@google.com, karlklose@google.com, jwren@google.com BUG= Review URL: https://codereview.chromium.org//521773003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39822 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
43b0e2d584
commit
2ccac8093b
43
tests/README
Normal file
43
tests/README
Normal file
|
@ -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.
|
20
tests/language/issue18628_1_test.dart
Normal file
20
tests/language/issue18628_1_test.dart
Normal file
|
@ -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<T> {
|
||||
// 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<Type> c = new C<Type>();
|
||||
print(c.t); /// 01: static type warning
|
||||
}
|
20
tests/language/issue18628_2_test.dart
Normal file
20
tests/language/issue18628_2_test.dart
Normal file
|
@ -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<T extends Type> {}
|
||||
|
||||
// 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<U> extends X<U> {} /// 01: static type warning
|
||||
|
||||
main() {
|
||||
X<Type> x = new X<Type>(); /// 01: static type warning
|
||||
Y<Type> y = new Y<Type>(); /// 01: static type warning
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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}.');
|
||||
|
|
Loading…
Reference in a new issue