9ed368c2e1
Refactor libraries so that JSCM will only use `JSStringImpl` class for strings. The goal is to disentangle the native string classes and `JSStringImpl` and start testing `JSStringImpl` in isolation. Changes: - `dart:_string` is no longer available in JSCM. - Make `int.toString` external to allow patching it differently in JSCM and normal modes. `toString` implementations are in `boxed_int_to_string.dart` patch files. - `int.parse` now uses JS `parseInt`. However `parseInt` is not compatible with Dart's `int.parse` so this will cause some more test failures in JSCM for now. - Any dependencies to `dart:_string` from JSCM `dart:convert` are removed. The library implementation now uses JS `TextDecoder` for UTF-8 decoding. Note: `TextDecoder` is not available on d8, so text decoding tests will fail on d8. JSON encoding and decoding in `dart:convert` will be updated in a follow-up CL. - Compiler (translator, constant generator, code generator etc.) is updated to allocate the `JSStringImpl`s in JSCM. Initially this will make some JSCM test fail as `int` parsing is not quite right, those will be fixed in follow-up CLs. Co-authored-by: Joshua Litt <joshualitt@google.com> Change-Id: I366e06f44cdc369d28fe47b24015234260304399 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332680 Reviewed-by: Aske Simon Christensen <askesc@google.com> Commit-Queue: Ömer Ağacan <omersa@google.com>
27 lines
599 B
Dart
27 lines
599 B
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 'dart:js_util';
|
|
import 'dart:js_interop';
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
@JS()
|
|
external void eval(String code);
|
|
|
|
void main() {
|
|
eval(r'''
|
|
globalThis.jsString = "hi";
|
|
''');
|
|
|
|
String jsString = getProperty(globalThis, "jsString");
|
|
|
|
switch (jsString) {
|
|
case "hi":
|
|
break;
|
|
default:
|
|
Expect.fail("Unexpected JS String: $jsString");
|
|
}
|
|
}
|