-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge 9383820 into dev
- Loading branch information
Showing
15 changed files
with
650 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,43 @@ | ||
// Copyright (c) 2022, 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. | ||
|
||
test1(dynamic x) { | ||
int a; | ||
[a] = x; | ||
return a; | ||
} | ||
|
||
test2(dynamic x) { | ||
int a, b, c; | ||
[c, ...] = [a && b, ...] = x; | ||
return a + b + c; | ||
} | ||
|
||
main() { | ||
expectEquals(test1([1]), 1); | ||
expectThrows(() => test1([])); | ||
expectThrows(() => test1([1, 2, 3])); | ||
expectThrows(() => test1("foo")); | ||
expectThrows(() => test1(null)); | ||
|
||
expectEquals(test2([1]), 3); | ||
expectThrows(() => test2(1)); | ||
} | ||
|
||
expectEquals(x, y) { | ||
if (x != y) { | ||
throw "Expected ${x} to be equal to ${y}."; | ||
} | ||
} | ||
|
||
expectThrows(void Function() f) { | ||
bool hasThrown = true; | ||
try { | ||
f(); | ||
hasThrown = false; | ||
} catch (e) {} | ||
if (!hasThrown) { | ||
throw "Expected the function to throw."; | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
pkg/front_end/testcases/patterns/simple_assignments.dart.strong.expect
This file contains 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,80 @@ | ||
library /*isNonNullableByDefault*/; | ||
import self as self; | ||
import "dart:core" as core; | ||
import "dart:_internal" as _in; | ||
|
||
static method test1(dynamic x) → dynamic { | ||
core::int a; | ||
block { | ||
final dynamic #t1 = x; | ||
final core::bool #t2 = true; | ||
final dynamic #t3 = #t1; | ||
if(#t3 is core::List<dynamic> && #t3{core::List<dynamic>}.{core::List::length}{core::int}.{core::num::==}(1){(core::Object) → core::bool}) { | ||
final dynamic #t4 = #t3{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}; | ||
if(let final dynamic #t5 = a = #t4 in true) { | ||
#t2 = false; | ||
} | ||
} | ||
if(#t2) | ||
throw new _in::ReachabilityError::•(); | ||
} =>#t1; | ||
return a; | ||
} | ||
static method test2(dynamic x) → dynamic { | ||
core::int a; | ||
core::int b; | ||
core::int c; | ||
block { | ||
final dynamic #t6 = block { | ||
final dynamic #t7 = x; | ||
final core::bool #t8 = true; | ||
final dynamic #t9 = #t7; | ||
if(#t9 is core::List<dynamic> && #t9{core::List<dynamic>}.{core::List::length}{core::int}.{core::num::>=}(1){(core::num) → core::bool}) { | ||
final dynamic #t10 = #t9{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}; | ||
final dynamic #t11 = #t10; | ||
if((let final dynamic #t12 = a = #t11 in true) && (let final dynamic #t13 = b = #t11 in true)) { | ||
#t8 = false; | ||
} | ||
} | ||
if(#t8) | ||
throw new _in::ReachabilityError::•(); | ||
} =>#t7; | ||
final core::bool #t14 = true; | ||
final dynamic #t15 = #t6; | ||
if(#t15 is core::List<dynamic> && #t15{core::List<dynamic>}.{core::List::length}{core::int}.{core::num::>=}(1){(core::num) → core::bool}) { | ||
final dynamic #t16 = #t15{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic}; | ||
if(let final dynamic #t17 = c = #t16 in true) { | ||
#t14 = false; | ||
} | ||
} | ||
if(#t14) | ||
throw new _in::ReachabilityError::•(); | ||
} =>#t6; | ||
return a.{core::num::+}(b){(core::num) → core::int}.{core::num::+}(c){(core::num) → core::int}; | ||
} | ||
static method main() → dynamic { | ||
self::expectEquals(self::test1(<core::int>[1]), 1); | ||
self::expectThrows(() → void => self::test1(<dynamic>[])); | ||
self::expectThrows(() → void => self::test1(<core::int>[1, 2, 3])); | ||
self::expectThrows(() → void => self::test1("foo")); | ||
self::expectThrows(() → void => self::test1(null)); | ||
self::expectEquals(self::test2(<core::int>[1]), 3); | ||
self::expectThrows(() → void => self::test2(1)); | ||
} | ||
static method expectEquals(dynamic x, dynamic y) → dynamic { | ||
if(!(x =={core::Object::==}{(core::Object) → core::bool} y)) { | ||
throw "Expected ${x} to be equal to ${y}."; | ||
} | ||
} | ||
static method expectThrows(() → void f) → dynamic { | ||
core::bool hasThrown = true; | ||
try { | ||
f(){() → void}; | ||
hasThrown = false; | ||
} | ||
on core::Object catch(final core::Object e) { | ||
} | ||
if(!hasThrown) { | ||
throw "Expected the function to throw."; | ||
} | ||
} |
Oops, something went wrong.