Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit 3902c22

Browse files
authored
Add tests showing lambda use. (#103)
1 parent 7792ab0 commit 3902c22

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

test/builders/class_test.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ void main() {
174174
constructor([
175175
lib$core.print.call([literal('Called constructor')]),
176176
]),
177+
new MethodBuilder(
178+
'toString',
179+
returns: literal(r'$Animal'),
180+
returnType: lib$core.String,
181+
),
177182
]),
178183
equalsSource(r'''
179184
class Animal {
@@ -186,6 +191,7 @@ void main() {
186191
void instanceMethod() {
187192
print('Called instanceMethod');
188193
}
194+
String toString() => '$Animal';
189195
}
190196
'''),
191197
);

test/builders/method_test.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ void main() {
7777
);
7878
});
7979

80+
test('should emit a function with a lambda expression', () {
81+
expect(
82+
new MethodBuilder('talk', returns: literal('Hello World')),
83+
equalsSource(r'''
84+
talk() => 'Hello World';
85+
'''),
86+
);
87+
});
88+
8089
group('constructors', () {
8190
test('should emit a simple constructor', () {
8291
expect(

0 commit comments

Comments
 (0)