[cfe] Add test for issue 51012

Closes #51012

Change-Id: I816b32daef41d305107a6fcba47ad3cb371c9a66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289903
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
This commit is contained in:
Johnni Winther 2023-03-22 08:53:45 +00:00 committed by Commit Queue
parent afdf640866
commit 54d437cd7e
9 changed files with 192 additions and 0 deletions

View file

@ -0,0 +1,22 @@
// 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.
int count = 0;
class A {
int get bar {
count++;
print('OK');
return 42;
}
}
main() {
var A(bar: _) = A();
expect(1, count);
}
expect(expected, actual) {
if (expected != actual) throw 'Expected $expected, actual $actual';
}

View file

@ -0,0 +1,28 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
import "dart:_internal" as _in;
class A extends core::Object {
synthetic constructor •() → self::A
: super core::Object::•()
;
get bar() → core::int {
self::count = self::count.{core::num::+}(1){(core::num) → core::int};
core::print("OK");
return 42;
}
}
static field core::int count = 0;
static method main() → dynamic {
{
final synthesized dynamic #0#0 = new self::A::•();
if(!(let final dynamic #t1 = #0#0{self::A}.{self::A::bar}{core::int} in true))
throw new _in::ReachabilityError::•();
}
self::expect(1, self::count);
}
static method expect(dynamic expected, dynamic actual) → dynamic {
if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))
throw "Expected ${expected}, actual ${actual}";
}

View file

@ -0,0 +1,28 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
import "dart:_internal" as _in;
class A extends core::Object {
synthetic constructor •() → self::A
: super core::Object::•()
;
get bar() → core::int {
self::count = self::count.{core::num::+}(1){(core::num) → core::int};
core::print("OK");
return 42;
}
}
static field core::int count = 0;
static method main() → dynamic {
{
final synthesized dynamic #0#0 = new self::A::•();
if(!(let final core::int #t1 = #0#0{self::A}.{self::A::bar}{core::int} in true))
throw new _in::ReachabilityError::•();
}
self::expect(1, self::count);
}
static method expect(dynamic expected, dynamic actual) → dynamic {
if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))
throw "Expected ${expected}, actual ${actual}";
}

View file

@ -0,0 +1,8 @@
int count = 0;
class A {
int get bar {}
}
main() {}
expect(expected, actual) {}

View file

@ -0,0 +1,7 @@
class A {
int get bar {}
}
expect(expected, actual) {}
int count = 0;
main() {}

View file

@ -0,0 +1,28 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
import "dart:_internal" as _in;
class A extends core::Object {
synthetic constructor •() → self::A
: super core::Object::•()
;
get bar() → core::int {
self::count = self::count.{core::num::+}(1){(core::num) → core::int};
core::print("OK");
return 42;
}
}
static field core::int count = 0;
static method main() → dynamic {
{
final synthesized dynamic #0#0 = new self::A::•();
if(!(let final dynamic #t1 = #0#0{self::A}.{self::A::bar}{core::int} in true))
throw new _in::ReachabilityError::•();
}
self::expect(1, self::count);
}
static method expect(dynamic expected, dynamic actual) → dynamic {
if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))
throw "Expected ${expected}, actual ${actual}";
}

View file

@ -0,0 +1,28 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
import "dart:_internal" as _in;
class A extends core::Object {
synthetic constructor •() → self::A
: super core::Object::•()
;
get bar() → core::int {
self::count = self::count.{core::num::+}(1){(core::num) → core::int};
core::print("OK");
return 42;
}
}
static field core::int count = 0;
static method main() → dynamic {
{
final synthesized dynamic #0#0 = new self::A::•();
if(!(let final dynamic #t1 = #0#0{self::A}.{self::A::bar}{core::int} in true))
throw new _in::ReachabilityError::•();
}
self::expect(1, self::count);
}
static method expect(dynamic expected, dynamic actual) → dynamic {
if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))
throw "Expected ${expected}, actual ${actual}";
}

View file

@ -0,0 +1,15 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
class A extends core::Object {
synthetic constructor •() → self::A
;
get bar() → core::int
;
}
static field core::int count;
static method main() → dynamic
;
static method expect(dynamic expected, dynamic actual) → dynamic
;

View file

@ -0,0 +1,28 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
import "dart:_internal" as _in;
class A extends core::Object {
synthetic constructor •() → self::A
: super core::Object::•()
;
get bar() → core::int {
self::count = self::count.{core::num::+}(1){(core::num) → core::int};
core::print("OK");
return 42;
}
}
static field core::int count = 0;
static method main() → dynamic {
{
final synthesized dynamic #0#0 = new self::A::•();
if(!(let final core::int #t1 = #0#0{self::A}.{self::A::bar}{core::int} in true))
throw new _in::ReachabilityError::•();
}
self::expect(1, self::count);
}
static method expect(dynamic expected, dynamic actual) → dynamic {
if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))
throw "Expected ${expected}, actual ${actual}";
}