Files
sdk/pkg/vm/test/bytecode/gen_bytecode_test.dart
T
Alexander Markov 253660db21 [vm/kernel/bytecode] Support corner cases of super calls in bytecode generator
* Super tear-offs: 'super.foo' where foo() is a method.
* Super calls of abstract members (useful with super-mixins).

Change-Id: I373b11c9773c7535e703cdc4e1bb9e632eef8dd2
Reviewed-on: https://dart-review.googlesource.com/64980
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-07-17 20:23:50 +00:00

43 lines
1.5 KiB
Dart

// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:io';
import 'package:kernel/ast.dart';
import 'package:kernel/kernel.dart';
import 'package:test/test.dart';
import 'package:vm/bytecode/gen_bytecode.dart' show generateBytecode;
import '../common_test_utils.dart';
final String pkgVmDir = Platform.script.resolve('../..').toFilePath();
runTestCase(Uri source) async {
// Certain tests require super-mixin semantics which is used in Flutter.
bool enableSuperMixins = source.pathSegments.last == 'super_calls.dart';
Component component = await compileTestCaseToKernelProgram(source,
enableSuperMixins: enableSuperMixins);
// Need to omit source positions from bytecode as they are different on
// Linux and Windows (due to differences in newline characters).
generateBytecode(component, strongMode: true, omitSourcePositions: true);
final actual = kernelLibraryToString(component.mainMethod.enclosingLibrary);
compareResultWithExpectationsFile(source, actual);
}
main() {
group('gen-bytecode', () {
final testCasesDir = new Directory(pkgVmDir + '/testcases/bytecode');
for (var entry
in testCasesDir.listSync(recursive: true, followLinks: false)) {
if (entry.path.endsWith(".dart")) {
test(entry.path, () => runTestCase(entry.uri));
}
}
});
}