Files
sdk/pkg/compiler/test/codegen/data/codeUnitAt_folding.dart
T
Stephen Adams d5e790b2b1 [dart2js] Add golden function codegen tests
As with other 'id_equivalence' tests, the information can be generated
via the '-g' flag.

Bug: 43778
Change-Id: I316d539f7575e349dc55ecb564de7b65f0f21575
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167480
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2020-10-14 22:32:38 +00:00

47 lines
1.0 KiB
Dart

// Copyright (c) 2020, 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.
@pragma('dart2js:noInline')
/*member: foo1:function() {
return 72;
}*/
foo1() {
var a = 'Hello';
var b = 0;
return a.codeUnitAt(b);
// Constant folds to 'return 72;'
}
@pragma('dart2js:noInline')
/*spec.member: foo2:function() {
return C.JSString_methods.codeUnitAt$1("Hello", H._asInt(1.5));
}*/
/*prod.member: foo2:function() {
return C.JSString_methods.codeUnitAt$1("Hello", 1.5);
}*/
foo2() {
var a = 'Hello';
dynamic b = 1.5;
return a.codeUnitAt(b);
// No folding of index type error.
}
@pragma('dart2js:noInline')
/*member: foo3:function() {
return C.JSString_methods._codeUnitAt$1("Hello", 55);
}*/
foo3() {
var a = 'Hello';
dynamic b = 55;
return a.codeUnitAt(b);
// No folding of index range error.
}
/*member: main:ignore*/
main() {
foo1();
foo2();
foo3();
}