ethanblake4 / dart_eval

Extensible Dart interpreter for Dart with full interop
https://pub.dev/packages/dart_eval
BSD 3-Clause "New" or "Revised" License
334 stars 40 forks source link

constructor logic not work #185

Closed HXiaoMing closed 9 months ago

HXiaoMing commented 9 months ago

test case:

import 'package:dart_eval/dart_eval.dart';
import 'package:test/expect.dart';
import 'package:test/scaffolding.dart';

void main() {

  group('constructor tests', () {

    test('test constructor logic', () {
      final program = '''
            class TestClass {

              int a = 1;

              TestClass() {
                a = 2;
              }

            }     

            int main () {
              final test = TestClass();
              return test.a;
            }
      ''';

      final result = eval(program, function: 'main');
      expect(result, 2);

    });

  });
}

Error: package:matcher expect test/custom/constructor_test.dart 28:7 main..

Expected: <2> Actual: <1>

ethanblake4 commented 9 months ago

Fixed in v0.7.6