Skip to content

Instantly share code, notes, and snippets.

@DreadBoy
Created November 30, 2020 05:56
Show Gist options
  • Save DreadBoy/b40fa474182b7cea6b6d93024c93f1a7 to your computer and use it in GitHub Desktop.
Save DreadBoy/b40fa474182b7cea6b6d93024c93f1a7 to your computer and use it in GitHub Desktop.
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