Move js_function_getter_trust_types_test off of unittest

Both html_individual_config.dart and unittest.dart are removed. Lack of
groups before were hiding what are now compile time errors, so static
error testing is introduced to handle them.

Change-Id: I1b87f7438f2ab301207cc401254206bcd77eb072
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138244
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
This commit is contained in:
Srujan Gaddam 2020-03-04 23:56:55 +00:00 committed by commit-bot@chromium.org
parent 72acbc18e6
commit b60e9ae71f
5 changed files with 73 additions and 31 deletions

View file

@ -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
}

View file

@ -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);
}

View file

@ -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));
});
}

View file

@ -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.

View file

@ -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