Skip to content

Commit

Permalink
Bind type spec
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanblake4 committed Mar 30, 2024
1 parent ec0c718 commit b06ed0d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
2 changes: 2 additions & 0 deletions lib/src/eval/bindgen/bindgen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class Bindgen {
class \$${element.name} implements \$Instance {
/// Configure this class for use in a [Runtime]
${bindConfigureForRuntime(ctx, element)}
/// Compile-time type specification of [\$${element.name}]
${bindTypeSpec(ctx, element)}
/// Compile-time type declaration of [\$${element.name}]
${bindBridgeType(ctx, element)}
/// Compile-time class declaration of [\$${element.name}]
Expand Down
16 changes: 10 additions & 6 deletions lib/src/eval/bindgen/bridge_declaration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@ import 'package:dart_eval/src/eval/bindgen/context.dart';
import 'package:dart_eval/src/eval/bindgen/parameters.dart';
import 'package:dart_eval/src/eval/bindgen/type.dart';

String bindBridgeType(BindgenContext ctx, ClassElement element) {
String bindTypeSpec(BindgenContext ctx, ClassElement element) {
return '''
static const \$type = BridgeTypeRef(
BridgeTypeSpec(
'${ctx.uri}',
'${element.name}',
),
static const \$spec = BridgeTypeSpec(
'${ctx.uri}',
'${element.name}',
);
''';
}

String bindBridgeType(BindgenContext ctx, ClassElement element) {
return '''
static const \$type = BridgeTypeRef(\$spec);
''';
}

String? bindBridgeDeclaration(BindgenContext ctx, ClassElement element) {
if (element.constructors.isEmpty) {
return null;
Expand Down
17 changes: 17 additions & 0 deletions test/exception_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -338,5 +338,22 @@ void main() {
expect(() => runtime.executeLib('package:example/main.dart', 'main'),
throwsA($String('error')));
});

test('Exception bubbles through asynchronous gap', () {
final runtime = compiler.compileWriteAndLoad({
'example': {
'main.dart': '''
import 'dart:async';
void main() async {
await Future.delayed(const Duration(milliseconds: 10));
throw 'error';
}
'''
}
});
expect(() => runtime.executeLib('package:example/main.dart', 'main'),
throwsA($String('error')));
});
});
}

0 comments on commit b06ed0d

Please sign in to comment.