Commit Graph

34 Commits

Author SHA1 Message Date
Robert Nystrom 13ce8baf76 Format tests/language/n*.
A lot of unspecified errors got filled in this time.

Change-Id: I88e728499da1b591ee1f6de1749f35182a6c9996
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408887
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2025-02-11 15:43:32 -08:00
Robert Nystrom 5bb9e922db Opt multitests out of formatting in language/.
The new formatter supports opting a region of code out from being
formatted. I'm applying this marker to all of the multitests since
those tests are often very sensitive to formatting and easily broken.
This way, anyone touching a multitest (including me when I reformat
the tests) doesn't have to remember to not run the formatter on it.

Unfortunately, this doesn't opt out 100# of the multitests. There are a
handful of multitests that also contain "@dart=" comments and are thus
formatted using the old style where the "// dart format off" marker has
no effect. For those, we'll have to still be careful to not accidentally
format them.

Change-Id: I257d0ee1eb44eee57047be06b8520f0ccc7b56d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396162
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2024-11-21 10:49:44 +00:00
Lasse R.H. Nielsen f8086c81ae Collect all test-related files in package:expect.
Collects files from `package:async_helper` and `tests/language`
that are generally useful, so that all test-related helpers are
in `package:expect`.

Moves the two libraries from `package:async_helper` into `package:expect`,
and the `tests/language/static_type_helper.dart` file too.

Deprecates `async_minitest.dart`, to follow `minitest.dart`,
expecting the Flutter use of it to have been fixed to not break
on deprecation (I believe Flutter no longer breaks builds on deprecations at all).

Patch 1 is the actual change.
Patch 2+4+8 is changing all existing references to the files.
Patch 6 ignores deprecation in files still using `async_minitest.dart`.

3+5+7+9 are updating this text to make the numbers match.
Then it's just test-expectations and small tweaks from there.

Change-Id: I1b665135b5fef9b9a0c3b340ffe9daf874d0174c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373120
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2024-10-11 16:53:52 +00:00
Erik Ernst fc7b4dda66 Adjust tests and spec_parser to updated grammar
This CL changes the specification parser grammar to support a switch
expression that has zero cases (this is a missing update, the feature
specification already has it). It also changes several language tests
such that they expect a 'syntax error' rather than a 'compile-time
error'. This makes no difference for any tool except the specification
parser, for which it is needed (in general, a test that is expected
to have a compile-time error will parse just fine, so we need a
separate test outcome expectation for syntax errors).

Change-Id: Ifa00c11ce6c57053bd490e11a41d6e8d7b82a2d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384600
Reviewed-by: Jonas Jensen <jonasfj@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2024-09-27 15:29:03 +00:00
Martin Kustermann a4d3ee054d [tests] Use asyncStart/asyncEnd for two language tests
In order for asynchronous tests to work on the web, they have to tell
the test runner that

* the test is async
* when the async test has finished running

This is done via calling asyncStart/asyncEnd.

Issue https://github.com/dart-lang/sdk/issues/52631
Issue https://github.com/dart-lang/sdk/issues/55865

Change-Id: I790960d7da708de4e36be9197ceb3e89f316a84e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368581
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-06-01 21:51:11 +00:00
Mayank Patke e78c0cf7a0 Remove language tests that opt out of null safety
Change-Id: I17409423f04f2eddebd4f20fd613cbcc9164dca5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347860
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2024-01-23 18:23:32 +00:00
Paul Berry 1de6bc74d2 Restore mixed-mode language tests.
This change reverts https://dart-review.googlesource.com/c/sdk/+/341020.

The reverted CL removed tests from `tests/language` that contained
legacy code (code with a language version less than 2.12). The primary
purpose of the removal was to unblock removal of legacy support from
the analyzer. It seemed safe to do because legacy code isn't supported
anymore, and no legacy code exists in google3 anymore. However,
several of those tests exercised important "weak mode" runtime
semantics of the web and VM platforms. See discussion at
https://dart-review.googlesource.com/c/sdk/+/341020/comments/bce31aa1_f5392ce1
for details.

This CL restores the deleted tests. Fortunately, since all the
restored tests are annotated with `Requirements=nnbd-weak`, they will
be skipped on the analyzer (thanks to
https://dart-review.googlesource.com/c/sdk/+/342080), so restoring
them no longer gets in the way of removing legacy support from the
analyzer.

Change-Id: Ib828be76f5c7eaeecaad0b7e7f7b0e3ff2f4bdb2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342090
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-12-19 13:50:18 +00:00
Paul Berry 454fe543ef Remove mixed-mode language tests.
Now that we no longer need to support legacy (pre-2.12) code in
google3, we don't need to test our support for it either.

Most of our language tests for legacy code were in `tests/language_2`
and have already been deleted; this CL addresses the few tests that
remain in `tests/language`, mostly dealing with "mixed mode" scenarios
(i.e., interactions between legacy code and null safe code).

Change-Id: I023d84547fdf17fb0599c82fbeb4fd07252ccf0f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341020
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-12-12 18:04:05 +00:00
Alexander Markov 487dd78a49 [test] Fix expectation in language/nnbd/static_errors/non_null_assertion_test
Null assertion `iq!` throws a runtime error, so the test should not
expect successful completion.

Change-Id: Ic1a59932ecdc0a4d18b1ff0c9a9b335038e0309c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304206
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2023-05-22 19:50:16 +00:00
Alexander Markov 7e4cf1d8ed [test] Fix incorrect expectation in language/nnbd/static_errors/unchecked_use_of_nullable_test/05
noSuchMethod() throws a runtime error, so the test should not expect
to complete successfully when calling noSuchMethod().

Change-Id: Ib1b7c3164771939b7c7374f08d86e1b216cab392
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304204
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2023-05-22 19:36:43 +00:00
Michael Thomsen e4cc3c98e5 [3.0 alpha] Remove deprecated dart:core List() constructor.
TEST=ci

Bug: Contributes to https://github.com/dart-lang/sdk/issues/49529
Change-Id: Ic129ef2d89f625d9ec6a7a1c301cffddd60b2ff7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258920
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Michael Thomsen <mit@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2022-12-15 11:36:22 +00:00
Lasse R.H. Nielsen 5642199dd0 Remove uses of : as default value separator in some tests/ directories.
Change-Id: I35bb926e53e92fd02e264fb5b14feadf063fb8db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257961
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-09-07 14:49:17 +00:00
Robert Nystrom 0e5417a48f Rename mis-named NNBD language tests.
Without "_test" in the name, the test runner ignores them.

Change-Id: I7dc2da51b980b1b5512fc2c2087238129bf1bd78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200930
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2021-05-28 01:12:07 +00:00
Ben Konyi d7ccc3ca6a Revert "Fix orphaned files in tests/language/ and tests/language_2/."
This reverts commit 1989b7f376.

Reason for revert: Bots are sad, red, and purple

Original change's description:
> Fix orphaned files in tests/language/ and tests/language_2/.
>
> Some of these should be tests but were missing "_test". Others seemed
> to simply be dead code. Some should have been referenced but there were
> mistakes in the imports in other files.
>
> Change-Id: If6f1d9e52a4babbf9883ddd437fc3091179f2ef2
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198141
> Auto-Submit: Bob Nystrom <rnystrom@google.com>
> Commit-Queue: Bob Nystrom <rnystrom@google.com>
> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>

TBR=lrn@google.com,leafp@google.com,rnystrom@google.com

Change-Id: I8d63af684023e99849addf9d1c3f87d6bcfbe89d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200531
Reviewed-by: Ben Konyi <bkonyi@google.com>
2021-05-18 21:28:01 +00:00
Robert Nystrom 1989b7f376 Fix orphaned files in tests/language/ and tests/language_2/.
Some of these should be tests but were missing "_test". Others seemed
to simply be dead code. Some should have been referenced but there were
mistakes in the imports in other files.

Change-Id: If6f1d9e52a4babbf9883ddd437fc3091179f2ef2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198141
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2021-05-18 00:36:52 +00:00
Lasse R.H. Nielsen d352bc28b8 Remove (most) uses of the "non-nullable" experiment flag.
Since the flag is now enabled by default, there should be no mention of it.
There are still some uses in front_end/testcases that are not just removable
(it also uses `no-non-nullable`). There migth be more uses that are not
as easily found as grepping for `--enable-experiment

Removes two VM tests where fixing them meant they were just duplicating
the corresponding non *_2/ tests.
Fixes #44941

TEST= Large number of tests chaged.=(no-)?non-nullable`.

Change-Id: Ief755981ccde9a5482fcdf408c2929c74433a710
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183688
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2021-02-12 17:16:54 +00:00
Paul Berry e933e91aaa Reland "Flow analysis: promote to non-nullable on initialization"
This is a reland of 6a1c54ec30

Original change's description:
> Flow analysis: promote to non-nullable on initialization
>
> When flow analysis encounters a variable declaration of the form `T? x
> = expr;`, if the type of `expr` is `T`, then the variable is
> immediately promoted to type `T`.
>
> Fixes #43099.
>
> Change-Id: Ia206fe0d50e2fdd9bdf637e13c85633d8490dbcc
> Bug: https://github.com/dart-lang/sdk/issues/43099
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163841
> Commit-Queue: Paul Berry <paulberry@google.com>
> Reviewed-by: Bob Nystrom <rnystrom@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>

Bug: https://github.com/dart-lang/sdk/issues/43099
Change-Id: I7530bb0f7c24674a7b500558b89d50b35e045aca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166305
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-07 13:14:55 +00:00
Clement Skau b4f49dc255 Revert "Flow analysis: promote to non-nullable on initialization"
This reverts commit 6a1c54ec30.

Reason for revert: Triggers test failure:
https://ci.chromium.org/p/dart/builders/ci.sandbox/vm-kernel-precomp-linux-debug-x64/8247

Original change's description:
> Flow analysis: promote to non-nullable on initialization
>
> When flow analysis encounters a variable declaration of the form `T? x
> = expr;`, if the type of `expr` is `T`, then the variable is
> immediately promoted to type `T`.
>
> Fixes #43099.
>
> Change-Id: Ia206fe0d50e2fdd9bdf637e13c85633d8490dbcc
> Bug: https://github.com/dart-lang/sdk/issues/43099
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163841
> Commit-Queue: Paul Berry <paulberry@google.com>
> Reviewed-by: Bob Nystrom <rnystrom@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>

TBR=paulberry@google.com,scheglov@google.com,rnystrom@google.com,johnniwinther@google.com

Change-Id: I8549b48a734f527194ce11d82235b9d5c6e58185
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/43099
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165564
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2020-10-01 08:41:15 +00:00
Paul Berry 6a1c54ec30 Flow analysis: promote to non-nullable on initialization
When flow analysis encounters a variable declaration of the form `T? x
= expr;`, if the type of `expr` is `T`, then the variable is
immediately promoted to type `T`.

Fixes #43099.

Change-Id: Ia206fe0d50e2fdd9bdf637e13c85633d8490dbcc
Bug: https://github.com/dart-lang/sdk/issues/43099
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163841
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-10-01 01:15:31 +00:00
Erik Ernst ecc87a177f Correct tests with unintended syntax errors
Change-Id: Id33f3088391815686b04f437cbf756b5718ed9bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163664
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2020-09-22 06:59:43 +00:00
Konstantin Shcheglov 8de8a1c226 Move codes from StaticTypeWarningCode into CompileTimeErrorCode.
They are all errors now.

Change-Id: If48d38e38e845fd5b5a950dd5514bf1cbbce03d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-07-27 16:44:15 +00:00
Konstantin Shcheglov ba92b78acd Move errors from StaticWarningCode to CompileTimeErrorCode.
Bug: https://github.com/dart-lang/sdk/issues/42821
Change-Id: I153c48d7a2e4a02026928e6203aacf8f2dc029ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155849
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-07-26 04:19:25 +00:00
Paul Berry 6547f741b6 Add language tests illustrating issue #42603.
Bug: https://github.com/dart-lang/sdk/issues/42603
Change-Id: I1d59b7b65d77e5f1accb4f9c3c99e92e48ffb364
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153709
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2020-07-13 18:12:39 +00:00
Leaf Petersen db36f1190f [Language] Various NNBD Tests.
Add a variety of small nnbd tests covering the specification
changes/clarifications landed in
https://github.com/dart-lang/language/pull/1003 .

Change-Id: I0716f14652128323bf103df154efb5bf978091d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150160
Commit-Queue: Leaf Petersen <leafp@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2020-06-05 23:53:20 +00:00
Robert Nystrom 114eea60bb Skip mixed-mode tests under language/nnbd in strong mode.
These tests all are or import legacy libraries, so are no longer
supported in NNBD strong mode. Adding Requirements=nnbd-weak tells the
test runner to skip that test when running in strong mode.

I deleted mixed_bottom_type_strong_test.dart entirely since it seems to
be specific to strong mode but is a legacy library. It is no longer
meaningful and there is already a corresponding weak test.

Change-Id: I5a8ec93114ad29abc3d12e356eeb7bf9efd3e1c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148234
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2020-05-21 17:34:43 +00:00
Liam Appelbe 87b829bacd [nnbd] Fix some more strong mode tests
All these tests now pass in both weak and strong mode, except for
relation_subclass_test and typedef_reflected_type_test. For those 2
tests I fixed the compile time error and now they have the same runtime
errors in both weak and strong mode (they were already failing at
runtime in weak mode).

Change-Id: If0157f811fffcf72a12ce6690ac0568c8f4419a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144343
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-04-22 00:12:24 +00:00
Konstantin Shcheglov 23a8788f6a Issue 41378. Update on-catch and throw for the spec changes.
Now it is not an error to use a potentially nullable type in on-catch.

But it is an error for throw an expression of type that is not
assignable to Object.

Bug: https://github.com/dart-lang/sdk/issues/41378
Change-Id: If0a198ae618cd01d03f45a46aa1efa6179df76ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143220
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-04-11 20:08:03 +00:00
Leaf Petersen b135aab6d7 Fix bad test expectation, convert to static error test
Change-Id: I821dd3af8c1be346d983bd41bb80efefba176cd5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143102
Auto-Submit: Leaf Petersen <leafp@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2020-04-10 18:07:44 +00:00
Konstantin Shcheglov 4a5e6e649a Update default_list_constructor_test to reflect that any use of the default List constructor is an error.
Change-Id: I97657eb8c44fd07c4940b757d6962534b8276e36
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140766
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-03-24 20:01:55 +00:00
Liam Appelbe ba9e4116ab [testing] Fix unchecked_use_of_nullable_test
typeParametersNullableBounds and typeParametersNullableUses are never
invoked, so can't generate runtime errors.

Bug: https://github.com/dart-lang/sdk/issues/39755
Change-Id: If1b17264c0376d0046851553e3ab282926c97da2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129201
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2019-12-20 16:40:20 +00:00
Konstantin Shcheglov d321f6e452 Issue 39773. Don't report MISSING_DEFAULT_VALUE_FOR_PARAMETER when no default value is allowed.
This partially reverts https://dart-review.googlesource.com/c/sdk/+/126801

Bug: https://github.com/dart-lang/sdk/issues/39773
Change-Id: Ib147ed770d9bf328dd7792a37a72291070411964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129142
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-12-19 23:35:13 +00:00
Leaf Petersen e50d98cd56 Fix some incorrect NNBD tests.
Closes https://github.com/dart-lang/sdk/issues/39814
Closes https://github.com/dart-lang/sdk/issues/39823
Closes https://github.com/dart-lang/sdk/issues/39816

Change-Id: I5015d5cb43b27a555360423cc9567c5880c948e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128777
Reviewed-by: Erik Ernst <eernst@google.com>
2019-12-19 18:43:03 +00:00
Konstantin Shcheglov 6c99171686 Report CompileTimeErrorCode.EXPORT_LEGACY_SYMBOL
Change-Id: Icd43121a4d7f20fdecc1bff8ced6b9378ce94149
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128377
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-12-14 01:14:55 +00:00
Robert Nystrom 3455133d98 Move NNBD tests (language_2/nnbd) to new NNBD test directory.
Change-Id: I0765a1e0fb19f38d7ad1c8655ba444f2f46fbf6a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128301
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2019-12-12 22:52:31 +00:00