mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
Fix bugs in implicit-creation tests. Add one more test.
Change-Id: Id5328ba0568d7eba78c2b9145ee2db3476dc5bd5 Reviewed-on: https://dart-review.googlesource.com/44961 Commit-Queue: Lasse R.H. Nielsen <lrn@google.com> Reviewed-by: Leaf Petersen <leafp@google.com> Reviewed-by: Peter von der Ahé <ahe@google.com>
This commit is contained in:
parent
d22ac9f071
commit
9986b6de25
6 changed files with 141 additions and 5 deletions
|
@ -0,0 +1,123 @@
|
|||
// Copyright (c) 2018, 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.
|
||||
|
||||
// Tests that const/new-insertion does the right thing for default values.
|
||||
// A default-value expression does not introduce a const context.
|
||||
|
||||
main() {
|
||||
foo();
|
||||
bar();
|
||||
baz();
|
||||
qux();
|
||||
C.foo();
|
||||
C.bar();
|
||||
new C().baz();
|
||||
new C().qux();
|
||||
new C.pos();
|
||||
new C.nam();
|
||||
const C.pos();
|
||||
const C.nam();
|
||||
}
|
||||
|
||||
// Default arguments must be const to be accepted
|
||||
foo([x //
|
||||
= const [C()] // //# o1: ok
|
||||
= const {42: C()} // //# o2: ok
|
||||
= const C(C()) // //# o3: ok
|
||||
= [42] // //# e1: compile-time error
|
||||
= {42: 42} // //# e2: compile-time error
|
||||
= C() // //# e3: compile-time error
|
||||
]) {
|
||||
}
|
||||
|
||||
bar({x //
|
||||
= const [C()] // //# o4: ok
|
||||
= const {42: C()} // //# o5: ok
|
||||
= const C(C()) // //# o6: ok
|
||||
= [42] // //# e4: compile-time error
|
||||
= {42: 42} // //# e5: compile-time error
|
||||
= C() // //# e6: compile-time error
|
||||
}) {
|
||||
}
|
||||
|
||||
var baz = ([x
|
||||
= const [C()] // //# o7: ok
|
||||
= const {42: C()} // //# o8: ok
|
||||
= const C(C()) // //# o9: ok
|
||||
= [42] // //# e7: compile-time error
|
||||
= {42: 42} // //# e8: compile-time error
|
||||
= C() // //# e9: compile-time error
|
||||
]) => 42;
|
||||
|
||||
var qux = ({x
|
||||
= const [C()] // //# o10: ok
|
||||
= const {42: C()} // //# o11: ok
|
||||
= const C(C()) // //# o12: ok
|
||||
= [42] // //# e10: compile-time error
|
||||
= {42: 42} // //# e11: compile-time error
|
||||
= C() // //# e12: compile-time error
|
||||
}) => 42;
|
||||
|
||||
class C {
|
||||
final x;
|
||||
const C([this.x]);
|
||||
|
||||
const C.pos([this.x //
|
||||
= const [C()] // //# o13: ok
|
||||
= const {42: C()} // //# o14: ok
|
||||
= const C(C()) // //# o15: ok
|
||||
= [42] // //# e13: compile-time error
|
||||
= {42: 42} // //# e14: compile-time error
|
||||
= C() // //# e15: compile-time error
|
||||
]);
|
||||
|
||||
const C.nam({this.x //
|
||||
= const [C()] // //# o16: ok
|
||||
= const {42: C()} // //# o17: ok
|
||||
= const C(C()) // //# o18: ok
|
||||
= [42] // //# e16: compile-time error
|
||||
= {42: 42} // //# e17: compile-time error
|
||||
= C() // //# e18: compile-time error
|
||||
});
|
||||
|
||||
static foo([x //
|
||||
= const [C()] // //# o19: ok
|
||||
= const {42: C()} // //# o20: ok
|
||||
= const C(C()) // //# o21: ok
|
||||
= [42] // //# e19: compile-time error
|
||||
= {42: 42} // //# e20: compile-time error
|
||||
= C() // //# e21: compile-time error
|
||||
]) {
|
||||
}
|
||||
|
||||
static bar({x //
|
||||
= const [C()] // //# o22: ok
|
||||
= const {42: C()} // //# o23: ok
|
||||
= const C(C()) // //# o24: ok
|
||||
= [42] // //# e22: compile-time error
|
||||
= {42: 42} // //# e23: compile-time error
|
||||
= C() // //# e24: compile-time error
|
||||
}) {
|
||||
}
|
||||
|
||||
baz([x //
|
||||
= const [C()] // //# o25: ok
|
||||
= const {42: C()} // //# o26: ok
|
||||
= const C(C()) // //# o27: ok
|
||||
= [42] // //# e25: compile-time error
|
||||
= {42: 42} // //# e26: compile-time error
|
||||
= C() // //# e27: compile-time error
|
||||
]) {
|
||||
}
|
||||
|
||||
qux({x //
|
||||
= const [C()] // //# o28: ok
|
||||
= const {42: C()} // //# o29: ok
|
||||
= const C(C()) // //# o30: ok
|
||||
= [42] // //# e28: compile-time error
|
||||
= {42: 42} // //# e29: compile-time error
|
||||
= C() // //# e30: compile-time error
|
||||
}) {
|
||||
}
|
||||
}
|
|
@ -35,7 +35,7 @@ main() {
|
|||
|
||||
Expect.identical(cd1, cd2);
|
||||
Expect.identical(cd1, cd3);
|
||||
Expect.allDistinct([cd1, cd3, cd4, cd5]);
|
||||
Expect.allDistinct([cd1, cd4, cd5]);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -95,7 +95,7 @@ main() {
|
|||
Expect.identical(n1, n3);
|
||||
Expect.identical(n1, n4);
|
||||
Expect.identical(n1, n8);
|
||||
Expect.allDistinct([n1, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14]);
|
||||
Expect.allDistinct([n1, n5, n6, n7, n9, n10, n11, n12, n13, n14]);
|
||||
|
||||
Expect.identical(clist, n6.left);
|
||||
Expect.identical(clist, n10.left);
|
||||
|
@ -183,7 +183,7 @@ main() {
|
|||
Expect.identical(l20, l23);
|
||||
Expect.identical(l20, l24);
|
||||
// List literals are never const unless in const context.
|
||||
Expect.allDistinct([l25, l26, l27, l28, l29, l30, l31]);
|
||||
Expect.allDistinct([l20, l25, l26, l27, l28, l29, l30, l31]);
|
||||
Expect.identical(cc42, l25[0]);
|
||||
Expect.identical(cc42, l26[0]);
|
||||
Expect.identical(cc42, l27[0]);
|
||||
|
@ -234,7 +234,7 @@ main() {
|
|||
Expect.identical(m20, m23);
|
||||
Expect.identical(m20, m24);
|
||||
// Map literals are never const unless in const context.
|
||||
Expect.allDistinct([m25, m26, m27, m28, m29, m30, m31]);
|
||||
Expect.allDistinct([m20, m25, m26, m27, m28, m29, m30, m31]);
|
||||
Expect.identical(cc42, m25.keys.first);
|
||||
Expect.identical(cc42, m26.keys.first);
|
||||
Expect.identical(cc42, m27.keys.first);
|
||||
|
|
|
@ -270,6 +270,7 @@ implicit_creation/implicit_const_context_prefix_constructor_generic_named_test:
|
|||
implicit_creation/implicit_const_context_prefix_constructor_generic_test: Fail # No support for implicit creation.
|
||||
implicit_creation/implicit_const_context_prefix_constructor_named_test: Fail # No support for implicit creation.
|
||||
implicit_creation/implicit_const_context_prefix_constructor_test: Fail # No support for implicit creation.
|
||||
implicit_creation/implicit_const_not_default_values_test/o.*: CompileTimeError # No support for implicit creation.
|
||||
implicit_creation/implicit_new_constructor_generic_named_test: Fail # No support for implicit creation.
|
||||
implicit_creation/implicit_new_constructor_named_test: Fail # No support for implicit creation.
|
||||
implicit_creation/implicit_new_or_const_composite_test: Fail # No support for implicit creation.
|
||||
|
|
|
@ -42,6 +42,7 @@ generic_methods_generic_function_parameter_test: CompileTimeError # Issue 28515
|
|||
generic_no_such_method_dispatcher_simple_test: Skip # This test is just for kernel.
|
||||
getter_declaration_negative_test: CompileTimeError
|
||||
getter_setter_in_lib_test: Fail # Issue 23286
|
||||
implicit_creation/implicit_const_not_default_values_test/o.*: CompileTimeError # No support for implicit creation.
|
||||
import_core_prefix_test: StaticWarning
|
||||
index_assign_operator_infer_return_type_test: StaticWarning
|
||||
initializing_formal_final_test: MissingCompileTimeError
|
||||
|
|
|
@ -97,6 +97,16 @@ implicit_creation/implicit_const_context_constructor_generic_named_test: Compile
|
|||
implicit_creation/implicit_const_context_constructor_generic_test: CompileTimeError
|
||||
implicit_creation/implicit_const_context_prefix_constructor_generic_named_test: CompileTimeError
|
||||
implicit_creation/implicit_const_context_prefix_constructor_generic_test: CompileTimeError
|
||||
implicit_creation/implicit_const_not_default_values_test/e12: MissingCompileTimeError
|
||||
implicit_creation/implicit_const_not_default_values_test/e15: MissingCompileTimeError
|
||||
implicit_creation/implicit_const_not_default_values_test/e18: MissingCompileTimeError
|
||||
implicit_creation/implicit_const_not_default_values_test/e21: MissingCompileTimeError
|
||||
implicit_creation/implicit_const_not_default_values_test/e24: MissingCompileTimeError
|
||||
implicit_creation/implicit_const_not_default_values_test/e27: MissingCompileTimeError
|
||||
implicit_creation/implicit_const_not_default_values_test/e3: MissingCompileTimeError
|
||||
implicit_creation/implicit_const_not_default_values_test/e30: MissingCompileTimeError
|
||||
implicit_creation/implicit_const_not_default_values_test/e6: MissingCompileTimeError
|
||||
implicit_creation/implicit_const_not_default_values_test/e9: MissingCompileTimeError
|
||||
implicit_creation/implicit_new_or_const_composite_test: RuntimeError
|
||||
implicit_creation/implicit_new_or_const_generic_test: RuntimeError
|
||||
implicit_downcast_during_compound_assignment_test: RuntimeError
|
||||
|
@ -460,6 +470,7 @@ identical_const_test/01: MissingCompileTimeError
|
|||
identical_const_test/02: MissingCompileTimeError
|
||||
identical_const_test/03: MissingCompileTimeError
|
||||
identical_const_test/04: MissingCompileTimeError
|
||||
implicit_creation/implicit_const_not_default_values_test/e.*: MissingCompileTimeError
|
||||
implicit_creation/implicit_new_or_const_composite_test: RuntimeError
|
||||
implicit_creation/implicit_new_or_const_test: RuntimeError
|
||||
implicit_this_test/01: MissingCompileTimeError
|
||||
|
|
|
@ -21,7 +21,6 @@ generic_no_such_method_dispatcher_test: RuntimeError # Issue 31424
|
|||
mock_writable_final_field_test: RuntimeError # Issue 31424
|
||||
no_such_method_subtype_test: RuntimeError # Issue 31424
|
||||
|
||||
|
||||
[ $fasta ]
|
||||
abstract_factory_constructor_test/00: MissingCompileTimeError # Issue 32013.
|
||||
abstract_getter_test/01: MissingCompileTimeError # Issue 32013.
|
||||
|
@ -642,6 +641,7 @@ generic_no_such_method_dispatcher_test: CompileTimeError # Issue 31533
|
|||
generic_tearoff_test: CompileTimeError
|
||||
generic_tearoff_test: RuntimeError
|
||||
if_null_evaluation_order_test: Pass
|
||||
implicit_creation/implicit_const_not_default_values_test/e.*: MissingCompileTimeError
|
||||
implicit_creation/implicit_new_constructor_generic_test: Pass
|
||||
initializing_formal_type_annotation_test/01: MissingCompileTimeError
|
||||
initializing_formal_type_annotation_test/02: MissingCompileTimeError
|
||||
|
|
Loading…
Reference in a new issue