mirror of
https://github.com/dart-lang/sdk
synced 2024-11-05 18:22:09 +00:00
61251c2c4e
Add regression test. Change-Id: I48f33b91b75f372e14ed5aa9185e79e105307573 Reviewed-on: https://dart-review.googlesource.com/16330 Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Régis Crelier <regis@google.com>
22 lines
535 B
Dart
22 lines
535 B
Dart
// Copyright (c) 2017, 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';
|
|
|
|
typedef Bar = int Function(int);
|
|
|
|
int defaultBar(int value) => value + 1;
|
|
|
|
class Foo {
|
|
final Bar bar;
|
|
|
|
const Foo._(Bar bar) : bar = bar ?? defaultBar;
|
|
|
|
const Foo.baz({Bar bar}) : this._(bar);
|
|
}
|
|
|
|
void main() {
|
|
final foo = const Foo.baz();
|
|
Expect.equals(2, foo.bar(1));
|
|
}
|