forked from dart-lang/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dart2js] Bailout tracing of record fields when record is bailed out
Fixes: dart-lang#52968 Change-Id: Ie59d4c0f903089622bc260d471bc136fa91eacde Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315020 Reviewed-by: Sigmund Cherem <[email protected]> Commit-Queue: Mayank Patke <[email protected]>
- Loading branch information
1 parent
5494c1c
commit b336f39
Showing
2 changed files
with
42 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// 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. | ||
|
||
import 'package:expect/expect.dart'; | ||
|
||
void main() { | ||
final validator = createValidator([ | ||
(validate: isNotEmpty, message: 'Value is required'), | ||
]); | ||
Expect.isEmpty(validator('foo')); | ||
Expect.isNotEmpty(validator(null)); | ||
} | ||
|
||
typedef FieldValidator<T> = List<String> Function(T? value); | ||
typedef Validator<T> = bool Function(T? value); | ||
FieldValidator<T> createValidator<T>( | ||
List<({Validator<T> validate, String message})> validators) => | ||
(T? value) { | ||
return validators | ||
.where((validator) => !validator.validate(value)) | ||
.map((validator) => validator.message) | ||
.toList(); | ||
}; | ||
|
||
bool isNotEmpty(String? value) => value != null && value.isNotEmpty; |