mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 09:43:08 +00:00
8d68480746
https://github.com/dart-lang/sdk/issues/43366 Fixed: 43366 Change-Id: Iac8247c31fa268186c8f2e3f52e0be1cac062598 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162247 Commit-Queue: Stephen Adams <sra@google.com> Reviewed-by: Mayank Patke <fishythefish@google.com> Reviewed-by: Sigmund Cherem <sigmund@google.com>
28 lines
632 B
Dart
28 lines
632 B
Dart
// 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.
|
|
|
|
String upcase(String? s) {
|
|
if (s == null) return '';
|
|
return s.toUpperCase();
|
|
}
|
|
|
|
String format(dynamic thing) {
|
|
if (thing is String?) return upcase(thing);
|
|
if (thing is num) return '$thing';
|
|
return '?';
|
|
}
|
|
|
|
main() {
|
|
log(format(null));
|
|
log(format('hello'));
|
|
log(format([]));
|
|
|
|
if (trace != '[][HELLO][?]') throw 'Unexpected: "$trace"';
|
|
}
|
|
|
|
String trace = '';
|
|
|
|
void log(String s) {
|
|
trace += '[$s]';
|
|
}
|