mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 03:17:55 +00:00
Add test for http://dartbug.com/51527
Test currently fails on both DDC and dart2js Bug: 51527 Change-Id: I229d5c9ba518d3323f98312f13740711523439e9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290350 Reviewed-by: Mark Zhou <markzipan@google.com> Commit-Queue: Stephen Adams <sra@google.com>
This commit is contained in:
parent
8e055884c5
commit
7675d887b3
33
tests/web/regress/issue/51527_test.dart
Normal file
33
tests/web/regress/issue/51527_test.dart
Normal file
|
@ -0,0 +1,33 @@
|
|||
// Copyright (c) 2023, 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.
|
||||
|
||||
// Regression test for http://dartbug.com/51527
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
void noop() {}
|
||||
dynamic makeNull() => null;
|
||||
|
||||
String test(String? o) {
|
||||
switch (o) {
|
||||
case null:
|
||||
return 'NULL';
|
||||
case 'one':
|
||||
return '1';
|
||||
default:
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
final String? s1 = 'one';
|
||||
final String? s2 = 'two';
|
||||
final String? s3 = Function.apply(makeNull, []);
|
||||
final String? s4 = Function.apply(noop, []);
|
||||
|
||||
Expect.equals('1', test(s1));
|
||||
Expect.equals('two', test(s2));
|
||||
Expect.equals('NULL', test(s3));
|
||||
Expect.equals('NULL', test(s4));
|
||||
}
|
33
tests/web_2/regress/issue/51527_test.dart
Normal file
33
tests/web_2/regress/issue/51527_test.dart
Normal file
|
@ -0,0 +1,33 @@
|
|||
// Copyright (c) 2023, 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.
|
||||
|
||||
// Regression test for http://dartbug.com/51527
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
void noop() {}
|
||||
dynamic makeNull() => null;
|
||||
|
||||
String test(String o) {
|
||||
switch (o) {
|
||||
case null:
|
||||
return 'NULL';
|
||||
case 'one':
|
||||
return '1';
|
||||
default:
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
final String s1 = 'one';
|
||||
final String s2 = 'two';
|
||||
final String s3 = Function.apply(makeNull, []);
|
||||
final String s4 = Function.apply(noop, []);
|
||||
|
||||
Expect.equals('1', test(s1));
|
||||
Expect.equals('two', test(s2));
|
||||
Expect.equals('NULL', test(s3));
|
||||
Expect.equals('NULL', test(s4));
|
||||
}
|
Loading…
Reference in a new issue