Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrinneal committed Apr 23, 2024
1 parent 1cdfc2a commit 4e5f4bf
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion packages/pigeon/lib/objc_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ class ObjcSourceGenerator extends StructuredGenerator<ObjcOptions> {
enumerate(getFieldsInSerializationOrder(classDefinition),
(int index, final NamedType field) {
final bool isEnumType = field.type.isEnum;
final String valueGetter = "GetNullableObjectAtIndex(list, $index)";
final String valueGetter = 'GetNullableObjectAtIndex(list, $index)';
final String? primitiveExtractionMethod =
_nsnumberExtractionMethod(field.type);
final String ivarValueExpression;
Expand Down
12 changes: 6 additions & 6 deletions packages/pigeon/test/kotlin_generator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ void main() {
expect(
code,
contains(
'val aInt = __pigeon_list[1].let { if (it is Int) it.toLong() else it as Long }'));
'val aInt = __pigeon_list[1].let { num -> if (num is Int) num.toLong() else num as Long }'));
expect(code, contains('val aNullableBool: Boolean? = null'));
expect(code, contains('val aNullableInt: Long? = null'));
expect(code, contains('val aNullableDouble: Double? = null'));
Expand All @@ -402,7 +402,7 @@ void main() {
expect(
code,
contains(
'val aNullableInt = __pigeon_list[9].let { if (it is Int) it.toLong() else it as Long? }'));
'val aNullableInt = __pigeon_list[9].let { num -> if (num is Int) num.toLong() else num as Long? }'));
});

test('gen one flutter api', () {
Expand Down Expand Up @@ -1162,11 +1162,11 @@ void main() {
expect(
code,
contains(
'val xArg = args[0].let { if (it is Int) it.toLong() else it as Long }'));
'val xArg = args[0].let { num -> if (num is Int) num.toLong() else num as Long }'));
expect(
code,
contains(
'val yArg = args[1].let { if (it is Int) it.toLong() else it as Long }'));
'val yArg = args[1].let { num -> if (num is Int) num.toLong() else num as Long }'));
expect(code, contains('listOf<Any?>(api.add(xArg, yArg))'));
expect(code, contains('reply.reply(wrapped)'));
});
Expand Down Expand Up @@ -1205,7 +1205,7 @@ void main() {
expect(
code,
contains(
'val output = it[0].let { if (it is Int) it.toLong() else it as Long }'),
'val output = it[0].let { num -> if (num is Int) num.toLong() else num as Long }'),
);
expect(code, contains('callback(Result.success(output))'));
expect(
Expand Down Expand Up @@ -1310,7 +1310,7 @@ void main() {
expect(
code,
contains(
'val fooArg = args[0].let { if (it is Int) it.toLong() else it as Long? }'));
'val fooArg = args[0].let { num -> if (num is Int) num.toLong() else num as Long? }'));
});

test('nullable argument flutter', () {
Expand Down
12 changes: 4 additions & 8 deletions packages/pigeon/test/objc_generator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,8 @@ void main() {
);
final String code = sink.toString();
expect(code, contains('@implementation Foobar'));
expect(
code,
contains(
'pigeonResult.aBool = GetNullableObjectAtIndex(__pigeon_list, 0);'));
expect(code,
contains('pigeonResult.aBool = GetNullableObjectAtIndex(list, 0);'));
});

test('nested class header', () {
Expand Down Expand Up @@ -602,10 +600,8 @@ void main() {
dartPackageName: DEFAULT_PACKAGE_NAME,
);
final String code = sink.toString();
expect(
code,
contains(
'pigeonResult.nested = GetNullableObjectAtIndex(__pigeon_list, 0);'));
expect(code,
contains('pigeonResult.nested = GetNullableObjectAtIndex(list, 0);'));
});

test('prefix class header', () {
Expand Down
3 changes: 2 additions & 1 deletion packages/pigeon/test/swift_generator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,8 @@ void main() {
expect(code, contains('var nested: Nested? = nil'));
expect(code,
contains('static func fromList(_ __pigeon_list: [Any?]) -> Outer?'));
expect(code, contains('nested = nestedList as Nested'));
expect(
code, contains('let nested: Nested? = nilOrValue(__pigeon_list[0])'));
expect(code, contains('func toList() -> [Any?]'));
expect(code, isNot(contains('if (')));
// Single-element list serializations should not have a trailing comma.
Expand Down
1 change: 1 addition & 0 deletions site-shared
Submodule site-shared added at 8c92e5

0 comments on commit 4e5f4bf

Please sign in to comment.