Created
November 30, 2020 05:56
-
-
Save DreadBoy/b40fa474182b7cea6b6d93024c93f1a7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import 'package:flutter_test/flutter_test.dart'; | |
void main() { | |
group('Dart', () { | |
test('compiler should recognise incorrect explicit type', () { | |
greet(String name) => name; | |
/// This would throw at compile time, that's expected and good | |
/// greet(007); | |
}); | |
test('compiler should warn about dynamic type', () { | |
greet(String name) => name; | |
final dynamic bond = 007; | |
/// This will throw at runtime | |
/// compiler should warn me I'm passing `dynamic` to `String` instead of | |
/// successfully compiling and then throwing at runtime | |
expect(greet(bond), returnsNormally); | |
}); | |
test('codesense should recognise parameters of HOF', () { | |
String Function(String surname) greet(String name) => | |
(surname) => '$name $surname'; | |
/// Pressing Ctrl+P when caret is inside second function ('James') doesn't | |
/// show list of parameters. Pressing it inside first function ('Bond') | |
/// will show it. | |
greet('Bond')('James'); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment