mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 03:47:13 +00:00
Add Record class to MockSdk, test with ConditionalExpression.
Change-Id: I49ae5de9b373b0a8582acc0cdcba67b3d8a26bc8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255960 Commit-Queue: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
parent
6785c2deb7
commit
490c03002b
|
@ -579,6 +579,8 @@ abstract class Pattern {
|
|||
Iterable<Match> allMatches(String string, [int start = 0]);
|
||||
}
|
||||
|
||||
abstract class Record {}
|
||||
|
||||
abstract class RegExp implements Pattern {
|
||||
external factory RegExp(String source, {bool unicode = false});
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
import 'package:analyzer/src/error/codes.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../context_collection_resolution.dart';
|
||||
import 'context_collection_resolution.dart';
|
||||
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
|
@ -63,6 +63,62 @@ ConditionalExpression
|
|||
''');
|
||||
}
|
||||
|
||||
test_recordType_differentShape() async {
|
||||
await assertNoErrorsInCode('''
|
||||
void f(bool b, (int, String) r1, ({int a}) r2) {
|
||||
b ? r1 : r2;
|
||||
}
|
||||
''');
|
||||
|
||||
final node = findNode.conditionalExpression('b ?');
|
||||
assertResolvedNodeText(node, r'''
|
||||
ConditionalExpression
|
||||
condition: SimpleIdentifier
|
||||
token: b
|
||||
staticElement: self::@function::f::@parameter::b
|
||||
staticType: bool
|
||||
question: ?
|
||||
thenExpression: SimpleIdentifier
|
||||
token: r1
|
||||
staticElement: self::@function::f::@parameter::r1
|
||||
staticType: (int, String)
|
||||
colon: :
|
||||
elseExpression: SimpleIdentifier
|
||||
token: r2
|
||||
staticElement: self::@function::f::@parameter::r2
|
||||
staticType: ({int a})
|
||||
staticType: Record
|
||||
''');
|
||||
}
|
||||
|
||||
test_recordType_sameShape_named() async {
|
||||
await assertNoErrorsInCode('''
|
||||
void f(bool b, ({int a}) r1, ({double a}) r2) {
|
||||
b ? r1 : r2;
|
||||
}
|
||||
''');
|
||||
|
||||
final node = findNode.conditionalExpression('b ?');
|
||||
assertResolvedNodeText(node, r'''
|
||||
ConditionalExpression
|
||||
condition: SimpleIdentifier
|
||||
token: b
|
||||
staticElement: self::@function::f::@parameter::b
|
||||
staticType: bool
|
||||
question: ?
|
||||
thenExpression: SimpleIdentifier
|
||||
token: r1
|
||||
staticElement: self::@function::f::@parameter::r1
|
||||
staticType: ({int a})
|
||||
colon: :
|
||||
elseExpression: SimpleIdentifier
|
||||
token: r2
|
||||
staticElement: self::@function::f::@parameter::r2
|
||||
staticType: ({double a})
|
||||
staticType: ({num a})
|
||||
''');
|
||||
}
|
||||
|
||||
test_type() async {
|
||||
await assertNoErrorsInCode('''
|
||||
void f(bool b) {
|
|
@ -12,6 +12,7 @@ import 'binary_expression_test.dart' as binary_expression;
|
|||
import 'class_alias_test.dart' as class_alias;
|
||||
import 'class_test.dart' as class_resolution;
|
||||
import 'comment_test.dart' as comment;
|
||||
import 'conditional_expression_test.dart' as conditional_expression;
|
||||
import 'constant_test.dart' as constant;
|
||||
import 'constructor_reference_test.dart' as constructor_reference;
|
||||
import 'constructor_test.dart' as constructor;
|
||||
|
@ -84,6 +85,7 @@ main() {
|
|||
binary_expression.main();
|
||||
class_alias.main();
|
||||
class_resolution.main();
|
||||
conditional_expression.main();
|
||||
comment.main();
|
||||
constant.main();
|
||||
constructor.main();
|
||||
|
|
|
@ -6,7 +6,6 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
|
|||
|
||||
import '../node_text_expectations.dart';
|
||||
import 'collection_elements_test.dart' as collection_elements;
|
||||
import 'conditional_expression_test.dart' as conditional_expression;
|
||||
import 'equality_expressions_test.dart' as equality_expressions;
|
||||
import 'extension_methods_test.dart' as extension_methods;
|
||||
import 'function_expression_test.dart' as function_expression;
|
||||
|
@ -25,7 +24,6 @@ import 'type_test_expressions_test.dart' as type_test_expressions;
|
|||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
collection_elements.main();
|
||||
conditional_expression.main();
|
||||
equality_expressions.main();
|
||||
extension_methods.main();
|
||||
function.main();
|
||||
|
|
Loading…
Reference in a new issue