Files
sdk/tests/web/native/javascript_bigint_test.dart
T
Stephen Adams 7f08f8e494 [dart2js] Add interceptors for JavaScript Symbol and BigInt
The interceptors provide a Dart `toString` method that uses the JavaScript `toString` method.

Issue: #53106

Change-Id: I1cf1df9e24fb4fd2d79679f1f014f39f083be7e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319563
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-08-10 14:42:38 +00:00

33 lines
910 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 'native_testing.dart';
import 'dart:_interceptors';
dynamic makeBigIntDynamic(String name) native;
JavaScriptBigInt makeBigInt(String name) native;
void setup() {
JS('', r"""
(function(){
self.makeBigInt = function(name){return BigInt(name)};
self.makeBigIntDynamic = function(name){return BigInt(name)};
})()""");
}
main() {
nativeTesting();
setup();
const s = '9876543210000000000000123456789';
Expect.notEquals(s, makeBigInt(s));
Expect.notEquals(s, makeBigIntDynamic(s));
Expect.equals(s, makeBigInt(s).toString());
Expect.equals(s, makeBigIntDynamic(s).toString());
Expect.equals(s, '${makeBigInt(s)}');
Expect.equals(s, '${makeBigIntDynamic(s)}');
}