|
| 1 | +// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file |
| 2 | +// for details. All rights reserved. Use of this source code is governed by a |
| 3 | +// BSD-style license that can be found in the LICENSE file. |
| 4 | + |
| 5 | +@Tags(['daily']) |
| 6 | +@Timeout(Duration(minutes: 2)) |
| 7 | + |
| 8 | +import 'package:dwds/src/debugging/inspector.dart'; |
| 9 | +import 'package:dwds/src/loaders/strategy.dart'; |
| 10 | +import 'package:test/test.dart'; |
| 11 | +import 'package:test_common/logging.dart'; |
| 12 | +import 'package:test_common/test_sdk_configuration.dart'; |
| 13 | + |
| 14 | +import '../fixtures/context.dart'; |
| 15 | +import '../fixtures/project.dart'; |
| 16 | + |
| 17 | +void main() { |
| 18 | + // Enable verbose logging for debugging. |
| 19 | + final debug = false; |
| 20 | + |
| 21 | + _runAllTests( |
| 22 | + canaryFeatures: true, |
| 23 | + compilationMode: CompilationMode.frontendServer, |
| 24 | + debug: debug, |
| 25 | + ); |
| 26 | +} |
| 27 | + |
| 28 | +void _runAllTests({ |
| 29 | + required bool canaryFeatures, |
| 30 | + required CompilationMode compilationMode, |
| 31 | + required bool debug, |
| 32 | +}) { |
| 33 | + group('canaryFeatures: $canaryFeatures |', () { |
| 34 | + final provider = TestSdkConfigurationProvider( |
| 35 | + canaryFeatures: canaryFeatures, |
| 36 | + verbose: debug, |
| 37 | + ); |
| 38 | + |
| 39 | + final project = TestProject.testScopesWithSoundNullSafety; |
| 40 | + |
| 41 | + setUpAll(() async { |
| 42 | + setCurrentLogWriter(debug: debug); |
| 43 | + // Cleanup project including compiled dart sdk. |
| 44 | + await project.cleanUp(); |
| 45 | + }); |
| 46 | + tearDownAll(provider.dispose); |
| 47 | + |
| 48 | + group('$compilationMode |', () { |
| 49 | + final context = TestContext(project, provider); |
| 50 | + late AppInspector inspector; |
| 51 | + |
| 52 | + setUpAll(() async { |
| 53 | + setCurrentLogWriter(debug: debug); |
| 54 | + await context.setUp( |
| 55 | + canaryFeatures: canaryFeatures, |
| 56 | + compilationMode: compilationMode, |
| 57 | + ); |
| 58 | + final chromeProxyService = context.service; |
| 59 | + inspector = chromeProxyService.inspector; |
| 60 | + }); |
| 61 | + |
| 62 | + tearDownAll(() async { |
| 63 | + await context.tearDown(); |
| 64 | + }); |
| 65 | + |
| 66 | + final url = 'org-dartlang-app:///example/scopes/main.dart'; |
| 67 | + |
| 68 | + String libraryName(CompilationMode compilationMode) => |
| 69 | + compilationMode == CompilationMode.frontendServer |
| 70 | + ? "example/scopes/main.dart" |
| 71 | + : "example/scopes/main"; |
| 72 | + |
| 73 | + String libraryVariableTypeExpression( |
| 74 | + String variable, |
| 75 | + CompilationMode compilationMode, |
| 76 | + ) => |
| 77 | + ''' |
| 78 | + (function() { |
| 79 | + var dart = ${globalLoadStrategy.loadModuleSnippet}('dart_sdk').dart; |
| 80 | + var libraryName = '${libraryName(compilationMode)}'; |
| 81 | + var library = dart.getModuleLibraries(libraryName)['$url']; |
| 82 | + var x = library['$variable']; |
| 83 | + return dart.getReifiedType(x); |
| 84 | + })(); |
| 85 | + '''; |
| 86 | + |
| 87 | + group('compiler', () { |
| 88 | + setUp(() => setCurrentLogWriter(debug: debug)); |
| 89 | + |
| 90 | + test('uses new type system', () async { |
| 91 | + final remoteObject = await inspector.jsEvaluate( |
| 92 | + libraryVariableTypeExpression( |
| 93 | + 'libraryPublicFinal', |
| 94 | + compilationMode, |
| 95 | + ), |
| 96 | + ); |
| 97 | + expect(remoteObject.json['className'], 'dart_rti.Rti.new'); |
| 98 | + }); |
| 99 | + }); |
| 100 | + }); |
| 101 | + }); |
| 102 | +} |
0 commit comments