dart-sdk/tests/language_strong/const_types_test.dart
Bob Nystrom 6c757957db Move the dev_compiler strong mode tests into sdk/tests/.
DDC's codegen test copies those files to a local "gen" directory so
that it can do stuff like splitting out the multitests before it
compiles them to JS.

I left all of that alone, so the rest of DDC's test infrastructure is
unchanged. The very first step that builds the "gen" directory just
copies from sdk/tests/..._strong/... instead and the rest is good to go.

I did not move not_yet_strong_tests.dart somewhere more accessible yet
because I'm not sure if kernel needs it or where it should go.

I did not create any status files because DDC doesn't need them and
there are no test suites for the new directories for the other
platforms.
2016-12-09 11:09:55 -08:00

85 lines
3.4 KiB
Dart

// Copyright (c) 2013, 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 handling of malformed types in constant expressions.
use(x) {}
class Class<T> implements Superclass {
const Class();
const Class.named();
void test() {
use(const []);
use(const <Class>[]);
use(const <Class<int>>[]);
use(const <Class<Unresolved>>[]); /// 01: static type warning
use(const <Unresolved>[]); /// 02: static type warning
use(const {});
use(const <Class>{}); /// 03: static type warning
use(const <String, Class>{});
use(const <String, Class<int>>{});
use(const <String, Class<Unresolved>>{}); /// 04: static type warning
use(const <String, Unresolved>{}); /// 05: static type warning
use(const Class());
use(const Class<int>());
use(const Class<Unresolved>()); /// 06: static type warning
use(const Class<T>()); /// 07: compile-time error
use(const Class<Class<T>>()); /// 08: compile-time error
use(const Unresolved()); /// 09: compile-time error
use(const Unresolved<int>()); /// 10: compile-time error
use(const prefix.Unresolved()); /// 11: compile-time error
use(const prefix.Unresolved<int>()); /// 12: compile-time error
use(const Class.named());
use(const Class<int>.named());
use(const Class<Unresolved>.named()); /// 13: static type warning
use(const Class<T>.named()); /// 14: compile-time error
use(const Class<Class<T>>.named()); /// 15: compile-time error
use(const Class.nonamed()); /// 16: compile-time error
use(const Class<int>.nonamed()); /// 17: compile-time error
use(const Class<Unresolved>.nonamed()); /// 18: compile-time error
use(const Class<T>.nonamed()); /// 19: compile-time error
use(const Class<Class<T>>.nonamed()); /// 20: compile-time error
use(const Unresolved.named()); /// 21: compile-time error
use(const Unresolved<int>.named()); /// 22: compile-time error
}
}
class Superclass<T> {
const factory Superclass() = Unresolved; /// 23: compile-time error
const factory Superclass() = Unresolved<int>; /// 24: compile-time error
const factory Superclass() = Unresolved.named; /// 25: compile-time error
const factory Superclass() = Unresolved<int>.named; /// 26: compile-time error
const factory Superclass() = prefix.Unresolved; /// 27: compile-time error
const factory Superclass() = prefix.Unresolved<int>; /// 28: compile-time error
const factory Superclass() = prefix.Unresolved.named; /// 29: compile-time error
const factory Superclass() = prefix.Unresolved<int>.named; /// 30: compile-time error
const factory Superclass() = Class; /// 31: ok
const factory Superclass() = Class<int>; /// 32: ok
const factory Superclass() = Class<T>; /// 33: ok
const factory Superclass() = Class<Class<T>>; /// 34: ok
const factory Superclass() = Class<Unresolved>; /// 35: static type warning
const factory Superclass() = Class.named; /// 36: ok
const factory Superclass() = Class<int>.named; /// 37: ok
const factory Superclass() = Class<T>.named; /// 38: ok
const factory Superclass() = Class<Class<T>>.named; /// 39: ok
const factory Superclass() = Class<Unresolved>.named; /// 40: static type warning
const factory Superclass() = T; /// 41: compile-time error
}
void main() {
new Class().test();
new Superclass();
}