-
Notifications
You must be signed in to change notification settings - Fork 84
Support records #1919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Support records #1919
Changes from 2 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
cb7251b
Display records and add tests
cbe8d96
Add _experiment test fixture
0e485cf
Update instanceRef kind to kRecord
c11b71d
Make offsets work
13a34ba
Merge branch 'master' of github.com:dart-lang/webdev into annagrin/re…
71c1fe8
Format
9c34b75
Require min versions of dds and vm_service that support records
96824c6
Cleanup and add more records tests
8fd379a
Cleanup names
56e23f9
Fix lists and maps getObject tests
5039cab
Fix records test failures
0adb558
Temporarily disabled failing record type tests
a0826c9
cleanup comments and formatting
aa36615
Merge branch 'master' of github.com:dart-lang/webdev into annagrin/re…
98119ca
Enable rectord type tests on main
31e23e0
Merge branch 'master' of github.com:dart-lang/webdev into annagrin/re…
733c7c6
Addressed CR comments, added tests for named parameters, fixed bugs
491ab13
Merge with master
0e280ae
Fix list count bug
9c4e8bf
Merge branch 'master' of github.com:dart-lang/webdev into annagrin/re…
2cff45a
Update min SDK constrain to support record types and enable skipped t…
19d64bc
Merge with master
b5202c7
Fix merge errors
dd31083
Fix failure on getObject of list with out of range offset
0b89601
Cleanup
689d6ba
Use JS logic to check for dart types
569321a
Addressed CR comments
bf6e585
Use integers as BoundField names for records
ded1222
Create positional fields faster, add comments
614d789
Cleaned up comments
a8c4700
Addressed comments
0a18c18
Address CR comments
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
// Copyright (c) 2020, 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. | ||
|
||
@TestOn('vm') | ||
@Timeout(Duration(minutes: 2)) | ||
|
||
import 'package:collection/collection.dart'; | ||
import 'package:dwds/src/connections/debug_connection.dart'; | ||
import 'package:dwds/src/services/chrome_proxy_service.dart'; | ||
import 'package:test/test.dart'; | ||
import 'package:vm_service/vm_service.dart'; | ||
|
||
import 'fixtures/context.dart'; | ||
import 'fixtures/logging.dart'; | ||
|
||
class TestSetup { | ||
TestContext context; | ||
|
||
TestSetup.sound() | ||
: context = TestContext.withSoundNullSafety( | ||
packageName: '_experiment', | ||
webAssetsPath: 'web', | ||
dartEntryFileName: 'main.dart', | ||
htmlEntryFileName: 'index.html', | ||
); | ||
|
||
ChromeProxyService get service => | ||
fetchChromeProxyService(context.debugConnection); | ||
} | ||
|
||
void main() async { | ||
// Enable verbose logging for debugging. | ||
final debug = true; | ||
|
||
final setup = TestSetup.sound(); | ||
final context = setup.context; | ||
|
||
Future<void> onBreakPoint(String isolate, ScriptRef script, | ||
String breakPointId, Future<void> Function() body) async { | ||
Breakpoint? bp; | ||
try { | ||
final line = | ||
await context.findBreakpointLine(breakPointId, isolate, script); | ||
bp = await setup.service | ||
.addBreakpointWithScriptUri(isolate, script.uri!, line); | ||
await body(); | ||
} finally { | ||
// Remove breakpoint so it doesn't impact other tests or retries. | ||
if (bp != null) { | ||
await setup.service.removeBreakpoint(isolate, bp.id!); | ||
} | ||
} | ||
} | ||
|
||
for (var compilationMode in [CompilationMode.frontendServer]) { | ||
group('$compilationMode |', () { | ||
setUpAll(() async { | ||
setCurrentLogWriter(debug: debug); | ||
}); | ||
|
||
group('shared context with evaluation |', () { | ||
setUpAll(() async { | ||
setCurrentLogWriter(debug: debug); | ||
await context.setUp( | ||
compilationMode: compilationMode, | ||
enableExpressionEvaluation: true, | ||
verboseCompiler: debug, | ||
experiments: ['records'], | ||
); | ||
}); | ||
|
||
tearDownAll(() async { | ||
await context.tearDown(); | ||
}); | ||
|
||
setUp(() => setCurrentLogWriter(debug: debug)); | ||
|
||
group('evaluateInFrame |', () { | ||
late String isolateId; | ||
late ScriptRef mainScript; | ||
late Stream<Event> stream; | ||
|
||
setUp(() async { | ||
setCurrentLogWriter(debug: debug); | ||
final vm = await setup.service.getVM(); | ||
isolateId = vm.isolates!.first.id!; | ||
final scripts = await setup.service.getScripts(isolateId); | ||
|
||
await setup.service.streamListen('Debug'); | ||
stream = setup.service.onEvent('Debug'); | ||
|
||
mainScript = scripts.scripts! | ||
.firstWhere((each) => each.uri!.contains('main.dart')); | ||
}); | ||
|
||
tearDown(() async { | ||
await setup.service.resume(isolateId); | ||
}); | ||
|
||
test('can evaluate and display records', () async { | ||
await onBreakPoint(isolateId, mainScript, 'printLocal', () async { | ||
final event = await stream.firstWhere( | ||
(event) => event.kind == EventKind.kPauseBreakpoint); | ||
|
||
final result = await setup.service | ||
.evaluateInFrame(isolateId, event.topFrame!.index!, 'record'); | ||
|
||
// Actual: InstanceRef:<[InstanceRef id: 5614429716467540672.1.54, kind: PlainInstance, identityHashCode: 912649884, classRef: [ClassRef id: classes|null|RecordType(bool, int), name: RecordType(bool, int), library: null]]> | ||
expect(result, isA<InstanceRef>()); | ||
|
||
final instanceRef = result as InstanceRef; | ||
final instance = await setup.service | ||
.getObject(isolateId, instanceRef.id!) as Instance; | ||
|
||
expect(instance.kind, InstanceKind.kRecord); | ||
|
||
final classRef = instance.classRef!; | ||
expect(classRef, isNotNull); | ||
expect(classRef.name, 'RecordType(bool, int)'); | ||
|
||
final fieldNames = instance.fields! | ||
.map((boundField) => boundField.name) | ||
.whereNotNull() | ||
.toList(); | ||
expect(fieldNames, [ | ||
r'$0', | ||
r'$1', | ||
]); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# This code is for testing that the debugger works with weak null-safety | ||
annagrin marked this conversation as resolved.
Show resolved
Hide resolved
annagrin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# so we should not migrate it to null-safety. | ||
# TODO(elliette): Delete this directory post Dart 3.0 (when we no longer | ||
# support weak null-safety). | ||
annagrin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
name: _experiment | ||
version: 1.0.0 | ||
description: >- | ||
A fake package used for testing experimental language features. | ||
publish_to: none | ||
|
||
environment: | ||
sdk: ">=3.0.0-134.0.dev<4.0.0" | ||
|
||
dependencies: | ||
intl: ^0.17.0 | ||
path: ^1.8.2 | ||
|
||
dev_dependencies: | ||
build_runner: ^2.4.0 | ||
build_web_compilers: ^4.0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<html> | ||
|
||
<head> | ||
<script defer src="main.dart.js"></script> | ||
</head> | ||
|
||
</html> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.