diff --git a/tests/lib_2/html/js_function_getter_trust_types/compile_test.dart b/tests/lib_2/html/js_function_getter_trust_types/compile_test.dart new file mode 100644 index 00000000000..9cbbe1fd360 --- /dev/null +++ b/tests/lib_2/html/js_function_getter_trust_types/compile_test.dart @@ -0,0 +1,52 @@ +// Copyright (c) 2020, 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. + +// SharedOptions=--trust-type-annotations +@JS() +library js_function_getter_trust_types_test; + +import 'package:js/js.dart'; +import 'package:expect/expect.dart'; + +import 'js_function_util.dart'; + +main() { + injectJs(); + + foo.bar.nonFunctionStatic(); +// ^ +// [cfe] Error: 'nonFunctionStatic' isn't a function or method and can't be invoked. +//^^^^^^^^^^^^^^^^^^^^^^^^^ +// [analyzer] STATIC_TYPE_WARNING.INVOCATION_OF_NON_FUNCTION_EXPRESSION + + foo.bar.nonFunctionStatic(0); +// ^ +// [cfe] Error: 'nonFunctionStatic' isn't a function or method and can't be invoked. +//^^^^^^^^^^^^^^^^^^^^^^^^^ +// [analyzer] STATIC_TYPE_WARNING.INVOCATION_OF_NON_FUNCTION_EXPRESSION + + foo.bar.nonFunctionStatic(0, 0); +// ^ +// [cfe] Error: 'nonFunctionStatic' isn't a function or method and can't be invoked. +//^^^^^^^^^^^^^^^^^^^^^^^^^ +// [analyzer] STATIC_TYPE_WARNING.INVOCATION_OF_NON_FUNCTION_EXPRESSION + + foo.bar.nonFunctionStatic(0, 0, 0, 0, 0, 0); +// ^ +// [cfe] Error: 'nonFunctionStatic' isn't a function or method and can't be invoked. +//^^^^^^^^^^^^^^^^^^^^^^^^^ +// [analyzer] STATIC_TYPE_WARNING.INVOCATION_OF_NON_FUNCTION_EXPRESSION + + foo.bar.add(4); + // ^ + // [cfe] Error: Too few positional arguments: 2 required, 1 given. + // ^^^ + // [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS + + foo.bar.add(4, 5, 10); + // ^ + // [cfe] Error: Too many positional arguments: 2 allowed, but 3 found. + // ^^^^^^^^^^ + // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS +} diff --git a/tests/lib_2/html/js_function_getter_trust_types/function_test.dart b/tests/lib_2/html/js_function_getter_trust_types/function_test.dart new file mode 100644 index 00000000000..5a49f47c2b5 --- /dev/null +++ b/tests/lib_2/html/js_function_getter_trust_types/function_test.dart @@ -0,0 +1,18 @@ +// Copyright (c) 2020, 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. + +// SharedOptions=--trust-type-annotations +@JS() +library js_function_getter_trust_types_test; + +import 'package:js/js.dart'; +import 'package:expect/expect.dart'; + +import 'js_function_util.dart'; + +main() { + injectJs(); + + Expect.equals(foo.bar.add(4, 5), 9); +} diff --git a/tests/lib_2/html/js_function_getter_trust_types_test.dart b/tests/lib_2/html/js_function_getter_trust_types/js_function_util.dart similarity index 56% rename from tests/lib_2/html/js_function_getter_trust_types_test.dart rename to tests/lib_2/html/js_function_getter_trust_types/js_function_util.dart index c91d6b36584..b6afd8f9c2a 100644 --- a/tests/lib_2/html/js_function_getter_trust_types_test.dart +++ b/tests/lib_2/html/js_function_getter_trust_types/js_function_util.dart @@ -9,11 +9,8 @@ library js_function_getter_trust_types_test; import 'dart:html'; import 'package:js/js.dart'; -import 'package:unittest/unittest.dart'; -import 'package:unittest/html_config.dart'; -import 'package:unittest/html_individual_config.dart'; -_injectJs() { +injectJs() { document.body.append(new ScriptElement() ..type = 'text/javascript' ..innerHtml = r""" @@ -49,22 +46,3 @@ abstract class Foo { @JS() external Foo get foo; - -main() { - _injectJs(); - - useHtmlIndividualConfiguration(); - - test('static nonFunctionStatic', () { - expect(() => foo.bar.nonFunctionStatic(), throws); - expect(() => foo.bar.nonFunctionStatic(0), throws); - expect(() => foo.bar.nonFunctionStatic(0, 0), throws); - expect(() => foo.bar.nonFunctionStatic(0, 0, 0, 0, 0, 0), throws); - }); - - test('typedef function', () { - expect(() => foo.bar.add(4), throws); - expect(() => foo.bar.add(4, 5, 10), throws); - expect(foo.bar.add(4, 5), equals(9)); - }); -} diff --git a/tests/lib_2/lib_2_analyzer.status b/tests/lib_2/lib_2_analyzer.status deleted file mode 100644 index 113c571b625..00000000000 --- a/tests/lib_2/lib_2_analyzer.status +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright (c) 2017, 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. - -[ $compiler == dart2analyzer ] -html/js_function_getter_trust_types_test: Skip # dart2js specific flags. diff --git a/tests/lib_2/lib_2_dart2js.status b/tests/lib_2/lib_2_dart2js.status index 93e9c115d05..14a0a1ada47 100644 --- a/tests/lib_2/lib_2_dart2js.status +++ b/tests/lib_2/lib_2_dart2js.status @@ -69,14 +69,14 @@ html/interactive_geolocation_test: Skip # Requires allowing geo location. [ $compiler == dart2js && $checked ] convert/utf85_test: Slow, Pass # Issue 12029. -html/js_function_getter_trust_types_test: Skip # --trust-type-annotations incompatible with --checked +html/js_function_getter_trust_types/function_test: Skip # --trust-type-annotations incompatible with --checked [ $compiler == dart2js && $csp && ($runtime == chrome || $runtime == chromeOnAndroid || $runtime == ff || $runtime == safari) ] html/event_customevent_test: SkipByDesign html/js_array_test: SkipByDesign html/js_dart_to_string_test: SkipByDesign html/js_function_getter_test: SkipByDesign -html/js_function_getter_trust_types_test: SkipByDesign +html/js_function_getter_trust_types/function_test: SkipByDesign html/js_interop_1_test: SkipByDesign html/js_typed_interop_bind_this_test: SkipByDesign html/js_typed_interop_callable_object_test: SkipByDesign