mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:19:48 +00:00
5642199dd0
Change-Id: I35bb926e53e92fd02e264fb5b14feadf063fb8db Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257961 Reviewed-by: Michael Thomsen <mit@google.com> Commit-Queue: Lasse Nielsen <lrn@google.com>
47 lines
1.4 KiB
Dart
47 lines
1.4 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 zero passed as an
|
|
// argument.
|
|
|
|
class TestClass {
|
|
TestClass();
|
|
|
|
num method([num value = 100]) => value;
|
|
num method2({num value = 100}) => value;
|
|
|
|
static num staticMethod([num value = 200]) => value;
|
|
static num staticMethod2({num value = 200}) => value;
|
|
}
|
|
|
|
num globalMethod([num value = 300]) => value;
|
|
num globalMethod2({num value = 300}) => value;
|
|
|
|
main() {
|
|
var obj = new TestClass();
|
|
|
|
Expect.equals(100, obj.method());
|
|
Expect.equals(100, obj.method2());
|
|
Expect.equals(7, obj.method(7));
|
|
Expect.equals(7, obj.method2(value: 7));
|
|
Expect.equals(0, obj.method(0));
|
|
Expect.equals(0, obj.method2(value: 0));
|
|
|
|
Expect.equals(200, TestClass.staticMethod());
|
|
Expect.equals(200, TestClass.staticMethod2());
|
|
Expect.equals(7, TestClass.staticMethod(7));
|
|
Expect.equals(7, TestClass.staticMethod2(value: 7));
|
|
Expect.equals(0, TestClass.staticMethod(0));
|
|
Expect.equals(0, TestClass.staticMethod2(value: 0));
|
|
|
|
Expect.equals(300, globalMethod());
|
|
Expect.equals(300, globalMethod2());
|
|
Expect.equals(7, globalMethod(7));
|
|
Expect.equals(7, globalMethod2(value: 7));
|
|
Expect.equals(0, globalMethod(0));
|
|
Expect.equals(0, globalMethod2(value: 0));
|
|
}
|