Skip to content

Commit

Permalink
[ddc] Add language version to test files
Browse files Browse the repository at this point in the history
Avoids breaks that appear when enabling the `nnbd` experiment
by default as seen in:
https://dart-review.googlesource.com/c/sdk/+/166790

Some of these synthetic files are created as packages but the
expression compiler wasn't designed to handle that information.
In the future we should support language versioning better in the
expression compiler or setup similar tests for opted in code since
in reality the language versioning might be handled by the dev
build system.

Fixes: #43843

Change-Id: Icfac40d1c9b47e75fb92d7672700e066ac372267
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168441
Reviewed-by: Anna Gringauze <annagrin@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
  • Loading branch information
nshahan authored and commit-bot@chromium.org committed Oct 20, 2020
1 parent 92704cf commit f396236
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ void main() {

group('Expression compiler tests in extension method:', () {
const source = '''
// @dart = 2.9
extension NumberParsing on String {
int parseInt() {
var ret = int.parse(this);
Expand Down Expand Up @@ -312,6 +313,7 @@ void main() {

group('Expression compiler tests in method:', () {
const source = '''
// @dart = 2.9
extension NumberParsing on String {
int parseInt() {
return int.parse(this);
Expand Down Expand Up @@ -565,6 +567,7 @@ void main() {

group('Expression compiler tests in method with no field access:', () {
const source = '''
// @dart = 2.9
extension NumberParsing on String {
int parseInt() {
return int.parse(this);
Expand Down Expand Up @@ -726,6 +729,7 @@ void main() {

group('Expression compiler tests in async method:', () {
const source = '''
// @dart = 2.9
class C {
C(int this.field, int this._field);
Expand Down Expand Up @@ -786,6 +790,7 @@ void main() {

group('Expression compiler tests in global function:', () {
const source = '''
// @dart = 2.9
extension NumberParsing on String {
int parseInt() {
return int.parse(this);
Expand Down Expand Up @@ -1044,6 +1049,7 @@ void main() {

group('Expression compiler tests in closures:', () {
const source = r'''
// @dart = 2.9
int globalFunction() {
int x = 15;
var c = C(1, 2);
Expand Down Expand Up @@ -1108,6 +1114,7 @@ void main() {

group('Expression compiler tests in method with no type use', () {
const source = '''
// @dart = 2.9
abstract class Key {
const factory Key(String value) = ValueKey;
const Key.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,14 @@ _testPackage:lib/
File.fromUri(main)
..createSync(recursive: true)
..writeAsStringSync('''
// @dart = 2.9
import 'package:_testPackage/test_library.dart';
var global = 0;
void main() {
var count = 0;
// line 7
// line 8
print('Global is: \${++global}');
print('Count is: \${++count}');
Expand All @@ -120,10 +121,11 @@ void main() {
File.fromUri(testLibrary)
..createSync()
..writeAsStringSync('''
// @dart = 2.9
import 'package:_testPackage/test_library2.dart';
int testLibraryFunction(int formal) {
return formal; // line 4
return formal; // line 5
}
int callLibraryFunction2(int formal) {
Expand All @@ -139,8 +141,9 @@ class B {
File.fromUri(testLibrary2)
..createSync()
..writeAsStringSync('''
// @dart = 2.9
int testLibraryFunction2(int formal) {
return formal; // line 2
return formal; // line 3
}
class C {
Expand Down Expand Up @@ -259,7 +262,7 @@ void main() async {
requestController.add({
'command': 'CompileExpression',
'expression': 'formal',
'line': 4,
'line': 5,
'column': 1,
'jsModules': {},
'jsScope': {'formal': 'formal'},
Expand Down Expand Up @@ -291,7 +294,7 @@ void main() async {
requestController.add({
'command': 'CompileExpression',
'expression': 'count',
'line': 7,
'line': 8,
'column': 1,
'jsModules': {},
'jsScope': {'count': 'count'},
Expand Down Expand Up @@ -324,7 +327,7 @@ void main() async {
requestController.add({
'command': 'CompileExpression',
'expression': 'B().c().getNumber()',
'line': 7,
'line': 8,
'column': 1,
'jsModules': {},
'jsScope': {},
Expand Down Expand Up @@ -445,7 +448,7 @@ void main() async {
requestController.add({
'command': 'CompileExpression',
'expression': 'formal',
'line': 4,
'line': 5,
'column': 1,
'jsModules': {},
'jsScope': {'formal': 'formal'},
Expand Down Expand Up @@ -477,7 +480,7 @@ void main() async {
requestController.add({
'command': 'CompileExpression',
'expression': 'count',
'line': 7,
'line': 8,
'column': 1,
'jsModules': {},
'jsScope': {'count': 'count'},
Expand Down

0 comments on commit f396236

Please sign in to comment.