Files
sdk/tests/language/parameter/named_passing_false_test.dart
Robert Nystrom 5c1376615e Migrate language_2/parameter to NNBD.
Change-Id: I369916a9edd3a9b38ab2c9ee1e11c4735331142b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150284
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2020-06-09 10:52:04 +00:00

47 lines
1.5 KiB
Dart

// Copyright (c) 2011, 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";
// Dart test program for testing named parameters with 'false' passed as an
// argument.
class TestClass {
TestClass();
bool? method([bool? value]) => value;
bool? method2({bool? value}) => value;
static bool? staticMethod([bool? value]) => value;
static bool? staticMethod2({bool? value}) => value;
}
bool? globalMethod([bool? value]) => value;
bool? globalMethod2({bool? value}) => value;
main() {
var obj = new TestClass();
Expect.equals(null, obj.method());
Expect.equals(null, obj.method2());
Expect.equals(true, obj.method(true));
Expect.equals(true, obj.method2(value: true));
Expect.equals(false, obj.method(false));
Expect.equals(false, obj.method2(value: false));
Expect.equals(null, TestClass.staticMethod());
Expect.equals(null, TestClass.staticMethod2());
Expect.equals(true, TestClass.staticMethod(true));
Expect.equals(true, TestClass.staticMethod2(value: true));
Expect.equals(false, TestClass.staticMethod(false));
Expect.equals(false, TestClass.staticMethod2(value: false));
Expect.equals(null, globalMethod());
Expect.equals(null, globalMethod2());
Expect.equals(true, globalMethod(true));
Expect.equals(true, globalMethod2(value: true));
Expect.equals(false, globalMethod(false));
Expect.equals(false, globalMethod2(value: false));
}