Files
sdk/pkg/dev_compiler/test/expression_compiler/assertions_enabled_test.dart
T
Anna Gringauze 3740e620cd Reland "[ddc] Add module local caches for new types"
This is a reland of commit a9fc9ffc4d

Additional changes:

- Set incremental mode on generic class table
  - fixes expression evaluation failure discovered by dwds tests
    (generic class table was not always defined in compiled expression)
- Allow expression evaluation while the app is running in e2e suite
- Add regression tests for the expression evaluation failure.

Original change's description:
> [ddc] Add module local caches for new types
>
> - Provides fast access for types that are used multiple times in the
>   same module.
> - Enable the existing type table cache when running with new types.
> - Add a similar cache for instantiated generic classes. This cache
>   is used in the current type system as well to help keep the
>   difference between types and classes more clear.
>
> Issue: https://github.com/dart-lang/sdk/issues/48585
> Change-Id: I32103cf0c0bcf9b9771e789c0d04e63a4365a066
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/321320
> Commit-Queue: Nicholas Shahan <nshahan@google.com>
> Reviewed-by: Mark Zhou <markzipan@google.com>

Change-Id: I9c31d1d07d7f9bb15645ac9aa6e91d35e8906e85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323501
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2023-09-01 21:10:09 +00:00

93 lines
2.8 KiB
Dart

// Copyright (c) 2023, 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 'package:test/test.dart';
import '../shared_test_options.dart';
import 'expression_compiler_e2e_suite.dart';
void main(List<String> args) async {
final debug = false;
var driver = await ExpressionEvaluationTestDriver.init();
var setup = SetupCompilerOptions(args: args);
setup.options.verbose = debug;
group('Asserts', () {
const source = r'''
void main() {
var b = const bool.fromEnvironment('dart.web.assertions_enabled');
// Breakpoint: bp
print('hello world');
}
int myAssert() {
assert(false);
return 0;
}
''';
setUpAll(() => driver.initSource(setup, source));
tearDownAll(() async {
await driver.cleanupTest();
await driver.finish();
});
if (setup.enableAsserts) {
group('enabled |', () {
test('dart.web.assertions_enabled is set', () async {
await driver.checkInFrame(
breakpointId: 'bp', expression: 'b', expectedResult: 'true');
});
test('assert errors in the source code', () async {
await driver.checkInFrame(
breakpointId: 'bp',
expression: 'myAssert()',
expectedError: allOf(
contains('Error: Assertion failed:'),
contains('test.dart:8:16'),
contains('false'),
contains('is not true'),
));
});
test('assert errors in evaluated expression', () async {
await driver.checkInFrame(
breakpointId: 'bp',
expression: '() { assert(false); return 0; } ()',
expectedError: allOf(
contains('Error: Assertion failed:'),
contains('<unknown source>:-1:-1'),
contains('BoolLiteral(false)'),
contains('is not true'),
));
});
});
}
if (!setup.enableAsserts) {
group('disabled |', () {
test('dart.web.assertions_enabled is not set', () async {
await driver.checkInFrame(
breakpointId: 'bp', expression: 'b', expectedResult: 'false');
});
test('no assert errors in the source code', () async {
await driver.checkInFrame(
breakpointId: 'bp',
expression: 'myAssert()',
expectedResult: '0');
});
test('no assert errors in evaluated expression', () async {
await driver.checkInFrame(
breakpointId: 'bp',
expression: '() { assert(false); return 0; } ()',
expectedResult: '0');
});
});
}
});
}