Skip to content

Adding tests for cross-module constant equality after hot restart in DDC #2349

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 14 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updating test comparison strings
  • Loading branch information
Markzipan committed Jan 22, 2024
commit f5096e027e4f9a8f056ee803d592f400f8ffca3d
60 changes: 36 additions & 24 deletions dwds/test/reload_correctness_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ void main() {
await client.streamListen('Isolate');

var source = await context.webDriver.pageSource;
expect(source, contains(constantSuccessString));
expect(source, isNot(contains(constantFailureString)));
expect(source, contains('reloadVariable: 23'));
expect(source, isNot(contains('reloadVariable: 45')));
expect(
source,
contains(
'ConstObject(reloadVariable: 23, ConstantEqualitySuccess)',
),
);

await makeEditAndWaitForRebuild();

Expand All @@ -98,10 +100,12 @@ void main() {
await eventsDone;

source = await context.webDriver.pageSource;
expect(source, contains(constantSuccessString));
expect(source, isNot(contains(constantFailureString)));
expect(source, contains('reloadVariable: 23'));
expect(source, contains('reloadVariable: 45'));
expect(
source,
contains(
'ConstObject(reloadVariable: 45, ConstantEqualitySuccess)',
),
);
});
},
timeout: Timeout.factor(2),
Expand All @@ -127,18 +131,22 @@ void main() {

test('properly compares constants after hot restart', () async {
var source = await context.webDriver.pageSource;
expect(source, contains(constantSuccessString));
expect(source, isNot(contains(constantFailureString)));
expect(source, contains('reloadVariable: 23'));
expect(source, isNot(contains('reloadVariable: 45')));
expect(
source,
contains(
'ConstObject(reloadVariable: 23, ConstantEqualitySuccess)',
),
);

await makeEditAndWaitForRebuild();

source = await context.webDriver.pageSource;
expect(source, contains(constantSuccessString));
expect(source, isNot(contains(constantFailureString)));
expect(source, contains('reloadVariable: 23'));
expect(source, contains('reloadVariable: 45'));
expect(
source,
contains(
'ConstObject(reloadVariable: 45, ConstantEqualitySuccess)',
),
);
});
});

Expand All @@ -161,18 +169,22 @@ void main() {

test('properly compares constants after hot restart', () async {
var source = await context.webDriver.pageSource;
expect(source, contains(constantSuccessString));
expect(source, isNot(contains(constantFailureString)));
expect(source, contains('reloadVariable: 23'));
expect(source, isNot(contains('reloadVariable: 45')));
expect(
source,
contains(
'ConstObject(reloadVariable: 23, ConstantEqualitySuccess)',
),
);

await makeEditAndWaitForRebuild();

source = await context.webDriver.pageSource;
expect(source, contains(constantSuccessString));
expect(source, isNot(contains(constantFailureString)));
expect(source, contains('reloadVariable: 23'));
expect(source, contains('reloadVariable: 45'));
expect(
source,
contains(
'ConstObject(reloadVariable: 45, ConstantEqualitySuccess)',
),
);
});
});
},
Expand Down
17 changes: 4 additions & 13 deletions fixtures/_testHotRestart2Sound/web/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,12 @@ import 'package:_test_hot_restart2/library2.dart';

class ConstObject {
const ConstObject();
String get text => 'ConstObject, '
String get text => 'ConstObject('
'reloadVariable: $variableToModifyToForceRecompile, '
'comparison: ${value1 == value2 ? 'ConstantEqualitySuccess' : 'ConstantEqualityFailure'}';
}

class ConstObjectWithField {
final int? a = null;
const ConstObjectWithField();
String get text => 'ConstObjectWithField, '
'reloadVariable: $variableToModifyToForceRecompile, '
'comparison: ${value1 == value2 ? 'ConstantEqualitySuccess' : 'ConstantEqualityFailure'}';
'${value1 == value2 ? 'ConstantEqualitySuccess' : 'ConstantEqualityFailure'})';
}

void main() {
document.body!.appendText('Program is running!\n');
document.body!.appendText('${const ConstObject().text}\n');
document.body!.appendText('${const ConstObjectWithField().text}\n');
document.body!.innerHtml =
'Program is running!\n${const ConstObject().text}\n';
}