mirror of
https://github.com/dart-lang/sdk
synced 2024-10-04 20:39:38 +00:00
Remove the legacy "_2" tests. \o/
I also cleaned up a bunch of places that referred to them. Change-Id: I45f68818c892f8620ea04257885ffa3763374bb5 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335863 Auto-Submit: Bob Nystrom <rnystrom@google.com> Commit-Queue: Bob Nystrom <rnystrom@google.com> Reviewed-by: Alexander Thomas <athom@google.com>
This commit is contained in:
parent
87d9b9d946
commit
2ee771a4f6
16
.gitattributes
vendored
16
.gitattributes
vendored
|
@ -18,27 +18,11 @@ tests/web/eof_line_ending_test.dart -text
|
|||
tests/web/string_interpolation_test.dart -text
|
||||
tests/web/string_interpolation_dynamic_test.dart -text
|
||||
tests/web/literal_string_juxtaposition_test.dart -text
|
||||
tests/web_2/eof_line_ending_test.dart -text
|
||||
tests/web_2/string_interpolation_test.dart -text
|
||||
tests/web_2/string_interpolation_dynamic_test.dart -text
|
||||
tests/web_2/literal_string_juxtaposition_test.dart -text
|
||||
tests/language/string/raw_string_test.dart -text
|
||||
tests/language/string/multiline_strings_test.dart -text
|
||||
tests/language/string/multiline_newline_cr.dart -text
|
||||
tests/language/string/multiline_newline_crlf.dart -text
|
||||
tests/language/string/multiline_newline_lf.dart -text
|
||||
tests/language_2/string/raw_string_test.dart -text
|
||||
tests/language_2/string/multiline_strings_test.dart -text
|
||||
tests/language_2/string/multiline_newline_cr.dart -text
|
||||
tests/language_2/string/multiline_newline_crlf.dart -text
|
||||
tests/language_2/string/multiline_newline_lf.dart -text
|
||||
tests/lib_2/convert/json_pretty_test.dart -text
|
||||
tests/lib_2/mirrors/method_mirror_source_line_ending_cr.dart -text
|
||||
tests/lib_2/mirrors/method_mirror_source_line_ending_crlf.dart -text
|
||||
tests/lib_2/mirrors/method_mirror_source_line_ending_lf.dart -text
|
||||
tests/lib_2/mirrors/method_mirror_source_line_ending_test.dart -text
|
||||
tests/lib_2/mirrors/method_mirror_source_other.dart -text
|
||||
tests/lib_2/mirrors/method_mirror_source_test.dart -text
|
||||
tests/lib/mirrors/method_mirror_source_line_ending_cr.dart -text
|
||||
tests/lib/mirrors/method_mirror_source_line_ending_crlf.dart -text
|
||||
tests/lib/mirrors/method_mirror_source_line_ending_lf.dart -text
|
||||
|
|
|
@ -88,14 +88,10 @@ class JsInteropChecks extends RecursiveVisitor {
|
|||
RegExp(r'(?<!generated_)tests/web/native'),
|
||||
RegExp(r'(?<!generated_)tests/web/internal'),
|
||||
'generated_tests/web/native/native_test',
|
||||
RegExp(r'(?<!generated_)tests/web_2/native'),
|
||||
RegExp(r'(?<!generated_)tests/web_2/internal'),
|
||||
'generated_tests/web_2/native/native_test',
|
||||
];
|
||||
|
||||
static final List<Pattern> _allowedTrustTypesTestPatterns = [
|
||||
RegExp(r'(?<!generated_)tests/lib/js'),
|
||||
RegExp(r'(?<!generated_)tests/lib_2/js'),
|
||||
];
|
||||
|
||||
/// Libraries that cannot be used when [_enforceStrictMode] is true.
|
||||
|
|
|
@ -18,7 +18,7 @@ conclusions on language samples in the testing directory.
|
|||
From the root of the SDK:
|
||||
|
||||
```
|
||||
tools/test.py --build --use-sdk -c dart2analyzer co19_2 language_2
|
||||
tools/test.py --build --use-sdk -c dart2analyzer co19 language
|
||||
```
|
||||
|
||||
This will build the Dart VM and compile dartanalyzer into a snapshot, then use
|
||||
|
|
|
@ -97,7 +97,7 @@ class BisectionConfig {
|
|||
start: '23f41452',
|
||||
end: '2c97bd78',
|
||||
testCommands: [
|
||||
'python3 tools/test.py --build -n dartk-linux-debug-x64 lib_2/isolate/package_resolve_test',
|
||||
'python3 tools/test.py --build -n dartk-linux-debug-x64 lib/isolate/package_resolve_test',
|
||||
],
|
||||
sdkPath: Directory.current.uri,
|
||||
failureString: "Error: The argument type 'String' can't "
|
||||
|
|
|
@ -41,10 +41,6 @@ List<Pattern> _allowedNativeTestPatterns = [
|
|||
RegExp(r'(?<!generated_)tests/web/internal'),
|
||||
'generated_tests/web/native/native_test',
|
||||
'generated_tests/web/internal/deferred_url_test',
|
||||
RegExp(r'(?<!generated_)tests/web_2/native'),
|
||||
RegExp(r'(?<!generated_)tests/web_2/internal'),
|
||||
'generated_tests/web_2/native/native_test',
|
||||
'generated_tests/web_2/internal/deferred_url_test',
|
||||
'pkg/front_end/testcases/dart2js/native',
|
||||
];
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ class HValidator extends HInstructionVisitor {
|
|||
// than this are OK in order to avoid the O(N^2) validation getting out of
|
||||
// hand.
|
||||
//
|
||||
// Poster child: corelib_2/regexp/pcre_test.dart, which has a 7KLOC main().
|
||||
// Poster child: corelib/regexp/pcre_test.dart, which has a 7KLOC main().
|
||||
static const int kMaxValidatedInstructionListLength = 1000;
|
||||
|
||||
/// Verifies [instruction] is contained in [instructions] [count] times.
|
||||
|
|
|
@ -16,7 +16,7 @@ main() {
|
|||
|
||||
test(List<String> options) async {
|
||||
DiagnosticCollector collector = DiagnosticCollector();
|
||||
String fileName = 'sdk/tests/web_2/native/main.dart';
|
||||
String fileName = 'sdk/tests/web/native/main.dart';
|
||||
Uri entryPoint = Uri.parse('memory:$fileName');
|
||||
await runCompiler(
|
||||
entryPoint: entryPoint,
|
||||
|
|
|
@ -20,9 +20,9 @@ const String TEST_1 = r"""
|
|||
main() {
|
||||
runTest() async {
|
||||
check(String test) async {
|
||||
// Pretend this is a web_2/native test to allow use of 'native' keyword
|
||||
// Pretend this is a web/native test to allow use of 'native' keyword
|
||||
// and import of private libraries.
|
||||
String main = 'sdk/tests/web_2/native/main.dart';
|
||||
String main = 'sdk/tests/web/native/main.dart';
|
||||
Uri entryPoint = Uri.parse('memory:$main');
|
||||
var result = await runCompiler(
|
||||
entryPoint: entryPoint, memorySourceFiles: {main: test});
|
||||
|
|
|
@ -89,7 +89,7 @@ main() {
|
|||
runTests() async {
|
||||
check(String test) async {
|
||||
var checker = checkerForAbsentPresent(test);
|
||||
String main = 'sdk/tests/web_2/native/main.dart';
|
||||
String main = 'sdk/tests/web/native/main.dart';
|
||||
Uri entryPoint = Uri.parse('memory:$main');
|
||||
var result = await runCompiler(
|
||||
entryPoint: entryPoint, memorySourceFiles: {main: test});
|
||||
|
|
|
@ -29,7 +29,7 @@ testClasses(String import1, String import2) async {
|
|||
{List<String> directlyInstantiated = const <String>[],
|
||||
List<String> abstractlyInstantiated = const <String>[],
|
||||
List<String> indirectlyInstantiated = const <String>[]}) async {
|
||||
String mainFile = 'sdk/tests/web_2/native/main.dart';
|
||||
String mainFile = 'sdk/tests/web/native/main.dart';
|
||||
Uri entryPoint = Uri.parse('memory:$mainFile');
|
||||
CompilationResult result =
|
||||
await runCompiler(entryPoint: entryPoint, memorySourceFiles: {
|
||||
|
|
|
@ -17,7 +17,7 @@ import 'package:kernel/ast.dart' as ir;
|
|||
import '../helpers/args_helper.dart';
|
||||
import 'package:compiler/src/util/memory_compiler.dart';
|
||||
|
||||
const String pathPrefix = 'sdk/tests/web_2/native/';
|
||||
const String pathPrefix = 'sdk/tests/web/native/';
|
||||
|
||||
const Map<String, String> source = {
|
||||
'$pathPrefix/main.dart': '''
|
||||
|
|
|
@ -18,7 +18,7 @@ enum Kind {
|
|||
|
||||
main() {
|
||||
asyncTest(() async {
|
||||
await runTest('tests/web_2/jsinterop_test.dart', '', {
|
||||
await runTest('tests/web/jsinterop_test.dart', '', {
|
||||
'Class': Kind.regular,
|
||||
'JsInteropClass': Kind.jsInterop,
|
||||
'flag': Kind.regular,
|
||||
|
@ -79,7 +79,7 @@ main() {
|
|||
'53',
|
||||
'54',
|
||||
]);
|
||||
await runTest('tests/web_2/non_jsinterop_test.dart', '', {
|
||||
await runTest('tests/web/non_jsinterop_test.dart', '', {
|
||||
'Class': Kind.regular,
|
||||
'JsInteropClass': Kind.jsInterop,
|
||||
'flag': Kind.regular,
|
||||
|
@ -139,7 +139,7 @@ main() {
|
|||
]);
|
||||
|
||||
await runTest(
|
||||
'tests/web_2/native/native_test.dart', 'tests/web_2/native/', {
|
||||
'tests/web/native/native_test.dart', 'tests/web/native/', {
|
||||
'Class': Kind.regular,
|
||||
'NativeClass': Kind.native,
|
||||
'topLevelField': Kind.regular,
|
||||
|
|
|
@ -17,9 +17,9 @@ main() {
|
|||
}
|
||||
|
||||
runTest() async {
|
||||
// Pretend this is a web_2/native test to allow use of 'native' keyword
|
||||
// Pretend this is a web/native test to allow use of 'native' keyword
|
||||
// and import of private libraries.
|
||||
String main = 'sdk/tests/web_2/native/main.dart';
|
||||
String main = 'sdk/tests/web/native/main.dart';
|
||||
Uri entryPoint = Uri.parse('memory:$main');
|
||||
|
||||
CompilationResult result =
|
||||
|
|
|
@ -509,9 +509,7 @@ class _CovarianceTransformer extends RecursiveVisitor {
|
|||
List<Pattern> _allowedNativeTestPatterns = [
|
||||
'tests/dartdevc',
|
||||
'tests/web/native',
|
||||
'tests/web_2/native',
|
||||
'tests/web/internal',
|
||||
'tests/web_2/internal',
|
||||
];
|
||||
|
||||
bool allowedNativeTest(Uri uri) {
|
||||
|
|
|
@ -1122,6 +1122,9 @@ class System extends NamedEnum {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO(rnystrom): NnbdMode.legacy can be removed now that opted out code is no
|
||||
// longer supported. This entire enum and the notion of "NNBD modes" can be
|
||||
// removed once it's no longer possible to run programs in unsound weak mode.
|
||||
/// What level of non-nullability support should be applied to the test files.
|
||||
class NnbdMode extends NamedEnum {
|
||||
/// "Opted out" legacy mode with no NNBD features allowed.
|
||||
|
|
|
@ -1098,7 +1098,7 @@ class Dart2jsCompilerCommandOutput extends CompilationCommandOutput
|
|||
/// Matches the location and message of a dart2js error message, which looks
|
||||
/// like:
|
||||
///
|
||||
/// tests/language_2/some_test.dart:9:3:
|
||||
/// tests/language/some_test.dart:9:3:
|
||||
/// Error: Some message.
|
||||
/// BadThing();
|
||||
/// ^
|
||||
|
@ -1130,7 +1130,7 @@ class Dart2WasmCompilerCommandOutput extends CompilationCommandOutput
|
|||
/// Matches the location and message of a dart2wasm error message, which looks
|
||||
/// like:
|
||||
///
|
||||
/// tests/language_2/some_test.dart:9:3: Error: Some message.
|
||||
/// tests/language/some_test.dart:9:3: Error: Some message.
|
||||
/// BadThing();
|
||||
/// ^
|
||||
///
|
||||
|
@ -1155,7 +1155,7 @@ class DevCompilerCommandOutput extends CommandOutput with _StaticErrorOutput {
|
|||
/// Matches the first line of a DDC error message. DDC prints errors to
|
||||
/// stdout that look like:
|
||||
///
|
||||
/// org-dartlang-app:/tests/language_2/some_test.dart:7:21: Error: Some message.
|
||||
/// org-dartlang-app:/tests/language/some_test.dart:7:21: Error: Some message.
|
||||
/// Try fixing the code to be less bad.
|
||||
/// var _ = <int>[if (1) 2];
|
||||
/// ^
|
||||
|
@ -1462,7 +1462,7 @@ class FastaCommandOutput extends CompilationCommandOutput
|
|||
/// Matches the first line of a Fasta error, warning, or context message.
|
||||
/// Fasta prints to stdout like:
|
||||
///
|
||||
/// tests/language_2/some_test.dart:7:21: Error: Some message.
|
||||
/// tests/language/some_test.dart:7:21: Error: Some message.
|
||||
/// Try fixing the code to be less bad.
|
||||
/// var _ = <int>[if (1) 2];
|
||||
/// ^
|
||||
|
|
|
@ -15,16 +15,6 @@ import 'repository.dart';
|
|||
import 'test_configurations.dart';
|
||||
import 'utils.dart';
|
||||
|
||||
const _legacyTestSelectors = [
|
||||
'corelib_2',
|
||||
'ffi_2',
|
||||
'language_2',
|
||||
'lib_2',
|
||||
'kernel',
|
||||
'utils',
|
||||
'vm',
|
||||
];
|
||||
|
||||
const _defaultTestSelectors = [
|
||||
'corelib',
|
||||
'ffi',
|
||||
|
@ -506,7 +496,6 @@ has been specified on the command line.''')
|
|||
var allSuiteDirectories = [
|
||||
...testSuiteDirectories,
|
||||
Path('tests/co19'),
|
||||
Path('tests/co19_2'),
|
||||
];
|
||||
|
||||
var selectors = <String>[];
|
||||
|
@ -523,8 +512,8 @@ has been specified on the command line.''')
|
|||
if (selector.startsWith('$path/')) {
|
||||
selector = selector.substring(path.lastIndexOf('/') + 1);
|
||||
|
||||
// Remove the `src/` subdirectories from the co19 and co19_2
|
||||
// directories that do not appear in the test names.
|
||||
// Remove the `src/` subdirectories from the co19 directories that do
|
||||
// not appear in the test names.
|
||||
if (selector.startsWith('co19')) {
|
||||
selector = selector.replaceFirst(RegExp('src/'), '');
|
||||
}
|
||||
|
@ -858,13 +847,9 @@ has been specified on the command line.''')
|
|||
.map((t) => t.split('/').first)
|
||||
.toSet()
|
||||
.toList();
|
||||
} else {
|
||||
if (nnbdMode == NnbdMode.legacy) {
|
||||
selectors.addAll(_legacyTestSelectors);
|
||||
} else {
|
||||
selectors.addAll(_defaultTestSelectors);
|
||||
}
|
||||
}
|
||||
|
||||
var excludeSuites = configuration['exclude-suite'] != null
|
||||
? (configuration['exclude-suite'] as String).split(',')
|
||||
|
|
|
@ -12,7 +12,7 @@ const _truncatedError =
|
|||
|
||||
/// Records the output from a test.
|
||||
class OutputLog implements StreamConsumer<List<int>> {
|
||||
// TODO(45618): Reduce this if language_2/unsorted/disassemble_test is fixed
|
||||
// TODO(45618): Reduce this if language/unsorted/disassemble_test is fixed
|
||||
// to produce less output and any other large-output tests are fixed.
|
||||
static const _maxLength = 10 * 1024 * 1024;
|
||||
|
||||
|
|
|
@ -34,18 +34,12 @@ final testSuiteDirectories = [
|
|||
Path('runtime/tests/vm'),
|
||||
Path('samples'),
|
||||
Path('tests/corelib'),
|
||||
Path('tests/corelib_2'),
|
||||
Path('tests/dartdevc'),
|
||||
Path('tests/dartdevc_2'),
|
||||
Path('tests/ffi'),
|
||||
Path('tests/ffi_2'),
|
||||
Path('tests/language'),
|
||||
Path('tests/language_2'),
|
||||
Path('tests/lib'),
|
||||
Path('tests/lib_2'),
|
||||
Path('tests/standalone'),
|
||||
Path('tests/web'),
|
||||
Path('tests/web_2'),
|
||||
Path('third_party/pkg/dart_style'),
|
||||
Path('third_party/pkg/dartdoc'),
|
||||
Path('third_party/pkg/native/pkgs/native_assets_builder'),
|
||||
|
@ -150,7 +144,7 @@ Future testConfigurations(List<TestConfiguration> configurations) async {
|
|||
}
|
||||
|
||||
for (var key in configuration.selectors.keys) {
|
||||
if (key == 'co19_2' || key == 'co19') {
|
||||
if (key == 'co19') {
|
||||
testSuites.add(Co19TestSuite(configuration, key));
|
||||
} else if (configuration.compiler == Compiler.dartk &&
|
||||
configuration.runtime == Runtime.vm &&
|
||||
|
|
|
@ -1110,7 +1110,7 @@ class AnalyzeLibraryTestSuite extends StandardTestSuite {
|
|||
|
||||
AnalyzeLibraryTestSuite(TestConfiguration configuration)
|
||||
: super(configuration, 'analyze_library', _libraryPath(configuration),
|
||||
['tests/lib_2/analyzer/analyze_library.status']);
|
||||
['tests/lib/analyzer/analyze_library.status']);
|
||||
|
||||
@override
|
||||
List<String> additionalOptions(Path? filePath, {bool? showSdkWarnings}) =>
|
||||
|
|
|
@ -103,23 +103,6 @@ void testValidation() {
|
|||
}
|
||||
|
||||
void testSelectors() {
|
||||
// Legacy suites.
|
||||
for (var arguments in [
|
||||
['--nnbd=legacy'],
|
||||
['-nvm-legacy']
|
||||
]) {
|
||||
var configuration = parseConfiguration(arguments);
|
||||
Expect.setEquals({
|
||||
'corelib_2',
|
||||
'language_2',
|
||||
'vm',
|
||||
'utils',
|
||||
'lib_2',
|
||||
'kernel',
|
||||
'ffi_2',
|
||||
}, configuration.selectors.keys, "suites for $arguments");
|
||||
}
|
||||
|
||||
// Default null safe suites.
|
||||
for (var arguments in [
|
||||
<String>[],
|
||||
|
@ -150,7 +133,7 @@ void testSelectors() {
|
|||
.join(Platform.pathSeparator);
|
||||
final co19Path = [
|
||||
'tests',
|
||||
'co19_2',
|
||||
'co19',
|
||||
'src',
|
||||
'subdir_1',
|
||||
'subdir_src',
|
||||
|
@ -161,14 +144,13 @@ void testSelectors() {
|
|||
// suite selectors, one with a pattern ending in .dart.
|
||||
// The final .dart is removed both from file paths and selector
|
||||
// patterns.
|
||||
['vm', 'language_2/a_legacy_test.dart', testPath, co19Path]);
|
||||
['vm', 'lib/a_legacy_test.dart', testPath, co19Path]);
|
||||
Expect.equals(
|
||||
'subdir/some_test', configuration.selectors['language']?.pattern);
|
||||
Expect.equals('subdir_1/subdir_src/some_co19_test',
|
||||
configuration.selectors['co19_2']?.pattern);
|
||||
configuration.selectors['co19']?.pattern);
|
||||
Expect.equals('.?', configuration.selectors['vm']?.pattern);
|
||||
Expect.equals(
|
||||
'a_legacy_test', configuration.selectors['language_2']?.pattern);
|
||||
Expect.equals('a_legacy_test', configuration.selectors['lib']?.pattern);
|
||||
}
|
||||
|
||||
TestConfiguration parseConfiguration(List<String> arguments) {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
//
|
||||
// Tests that a basic test still works when instructions are deduplicated.
|
||||
// Test body comes from tests/corelib_2/apply2_test.dart, which is one of the
|
||||
// Test body comes from tests/corelib/apply2_test.dart, which is one of the
|
||||
// tests that were failing when --dedup-instructions was broken in bare payload
|
||||
// mode (precompiled + bare instructions).
|
||||
//
|
||||
|
|
|
@ -3271,7 +3271,7 @@ void applyExtension(name, nativeObject) {}
|
|||
// This is currently a no-op in dart2js, but used for native tests.
|
||||
void applyTestExtensions(List<String> names) {}
|
||||
|
||||
// See tests/web_2/platform_environment_variable1_test.dart
|
||||
// See tests/web/platform_environment_variable1_test.dart
|
||||
const String testPlatformEnvironmentVariableValue = String.fromEnvironment(
|
||||
'dart2js.test.platform.environment.variable',
|
||||
defaultValue: 'not-specified');
|
||||
|
|
1
tests/co19_2/.gitignore
vendored
1
tests/co19_2/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
/src
|
|
@ -1,132 +0,0 @@
|
|||
# Copyright (c) 2019, 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.
|
||||
|
||||
Language/Generics/Superbounded_types/typedef1_A01_t03: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
Language/Generics/Superbounded_types/typedef1_A01_t04: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
Language/Generics/Superbounded_types/typedef2_A01_t04: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
Language/Generics/typedef_A08_t02: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
Language/Generics/typedef_A08_t03: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
Language/Generics/typedef_A08_t04: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/class/static/class_typedef_l1_t03: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/class/static/class_typedef_l2_t03: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/class/static/class_typedef_l2_t07: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l1_t03: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l1_t04: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l1_t05: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l1_t08: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l1_t09: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l1_t10: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_01_t01: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_01_t02: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_01_t03: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_01_t04: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_01_t06: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_01_t07: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_01_t08: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_01_t09: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_01_t10: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_01_t11: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_01_t12: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_01_t13: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_01_t14: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_01_t15: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_01_t16: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_01_t17: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_01_t18: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_01_t19: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_01_t20: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_02_t01: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_02_t03: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_02_t06: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_02_t07: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_02_t08: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_02_t09: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_02_t10: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_02_t11: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_02_t14: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_02_t15: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_02_t16: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_02_t17: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_02_t18: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_02_t19: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_02_t20: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_03_t02: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_03_t04: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_03_t06: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_03_t07: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_03_t08: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_03_t09: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_03_t12: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_03_t13: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_03_t14: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_03_t15: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_03_t16: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_03_t17: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_03_t18: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_03_t19: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_03_t20: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_04_t01: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_04_t02: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_04_t03: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_04_t04: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_04_t06: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_04_t07: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_04_t08: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_04_t09: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_04_t10: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_04_t11: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_04_t12: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_04_t13: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_04_t14: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_04_t15: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_04_t16: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_04_t17: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_04_t18: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_04_t19: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_04_t20: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_05_t01: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_05_t02: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_05_t03: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_05_t04: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_05_t06: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_05_t07: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_05_t08: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_05_t09: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_05_t10: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_05_t11: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_05_t12: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_05_t13: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_05_t14: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_05_t15: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_05_t16: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_05_t17: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_05_t18: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_05_t19: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_05_t20: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_06_t01: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_06_t02: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_06_t03: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_06_t06: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_06_t07: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_06_t08: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_06_t09: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_06_t10: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_06_t11: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_06_t12: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_06_t13: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_06_t14: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_06_t15: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_06_t16: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_06_t17: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_06_t18: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_06_t19: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_06_t20: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_typedef_l1_t03: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_typedef_l1_t07: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_typedef_l1_t09: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_typedef_l1_t11: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_typedef_l1_t13: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_typedef_l1_t15: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_typedef_l1_t17: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_typedef_l1_t19: SkipByDesign # https://github.com/dart-lang/sdk/issues/46483
|
|
@ -1,90 +0,0 @@
|
|||
# Copyright (c) 2012, 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.
|
||||
|
||||
[ $compiler == dart2js ]
|
||||
Language/Expressions/Constants/integer_size_t03: SkipByDesign # uses integer literal not representable as JavaScript number
|
||||
Language/Expressions/Constants/integer_size_t04: SkipByDesign # uses integer literal not representable as JavaScript number
|
||||
Language/Expressions/Constants/literal_number_t01: SkipByDesign # uses integer literal not representable as JavaScript number
|
||||
Language/Expressions/Constants/math_operators_t01: SkipByDesign # uses integer literal not representable as JavaScript number
|
||||
Language/Expressions/Constants/math_operators_t06: SkipByDesign # uses integer literal not representable as JavaScript number
|
||||
Language/Expressions/Numbers/integer_size_t03: SkipByDesign # uses integer literal not representable as JavaScript number
|
||||
Language/Expressions/Numbers/static_type_of_int_t01: SkipByDesign # uses integer literal not representable as JavaScript number
|
||||
Language/Expressions/Numbers/syntax_t06: SkipByDesign # uses integer literal not representable as JavaScript number
|
||||
Language/Expressions/Numbers/syntax_t09: SkipByDesign # uses integer literal not representable as JavaScript number
|
||||
Language/Expressions/Object_Identity/object_t02: SkipByDesign # https://github.com/dart-lang/sdk/issues/42222#issuecomment-640431711
|
||||
Language/Expressions/Spawning_an_Isolate/new_isolate_t01: SkipByDesign
|
||||
Language/Functions/External_Functions/not_connected_to_a_body_t01: SkipByDesign # Non-JS-interop external members are not supported
|
||||
Language/Libraries_and_Scripts/Scripts/top_level_main_t01: SkipByDesign # Uses dart:io.
|
||||
Language/Libraries_and_Scripts/Scripts/top_level_main_t06: SkipByDesign # Uses dart:io.
|
||||
Language/Libraries_and_Scripts/Scripts/top_level_syntax_t01: SkipByDesign # Non-JS-interop external members are not supported
|
||||
Language/Libraries_and_Scripts/top_level_syntax_t01: SkipByDesign # Non-JS-interop external members are not supported
|
||||
Language/Reference/Operator_Precedence/precedence_15_unary_prefix_t08: SkipByDesign # binary '~' produces different results in JavaScript and Dart
|
||||
Language/Types/Interface_Types/subtype_t27: Skip # https://github.com/dart-lang/sdk/issues/42641
|
||||
LibTest/core/DateTime/DateTime.fromMicrosecondsSinceEpoch_A01_t01: SkipByDesign # microseconds are not supported in JavaScript
|
||||
LibTest/core/DateTime/microsecond_A01_t01: SkipByDesign # microseconds are not supported in JavaScript
|
||||
LibTest/core/DateTime/microsecondsSinceEpoch_A01_t01: SkipByDesign # microseconds are not supported in JavaScript
|
||||
LibTest/core/DateTime/parse_A01_t03: SkipByDesign # microseconds are not supported in JavaScript
|
||||
LibTest/core/DateTime/to8601String_A01_t01: SkipByDesign # microseconds are not supported in JavaScript
|
||||
LibTest/core/DateTime/to8601String_A01_t02: SkipByDesign # microseconds are not supported in JavaScript
|
||||
LibTest/core/DateTime/to8601String_A01_t03: SkipByDesign # microseconds are not supported in JavaScript
|
||||
LibTest/core/int/operator_remainder_A01_t03: SkipByDesign # Division by zero is not an error in JavaScript
|
||||
LibTest/core/int/operator_truncating_division_A01_t02: SkipByDesign # Division by zero is not an error in JavaScript
|
||||
LibTest/core/int/parse_A01_t02: SkipByDesign # big integers cannot be represented in JavaScript
|
||||
LibTest/core/int/remainder_A01_t03: SkipByDesign # Division by zero is not an error in JavaScript
|
||||
LibTest/io/*: SkipByDesign # dart:io not supported.
|
||||
LibTest/isolate/*: SkipByDesign # dart:isolate not supported
|
||||
LibTest/mirrors/*: SkipByDesign # dart:mirrors not supported
|
||||
LibTest/typed_data/ByteBuffer/asInt64List_A01_t01: SkipByDesign # Int64List not supported on the web
|
||||
LibTest/typed_data/ByteBuffer/asInt64List_A02_t01: SkipByDesign # Int64List not supported on the web
|
||||
LibTest/typed_data/ByteBuffer/asInt64List_A03_t01: SkipByDesign # Int64List not supported on the web
|
||||
LibTest/typed_data/ByteBuffer/asUint64List_A01_t01: SkipByDesign # UInt64List not supported on the web
|
||||
LibTest/typed_data/ByteBuffer/asUint64List_A02_t01: SkipByDesign # UInt64List not supported on the web
|
||||
LibTest/typed_data/ByteBuffer/asUint64List_A03_t01: SkipByDesign # UInt64List not supported on the web
|
||||
LibTest/typed_data/ByteData/getInt64_A01_t01: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/ByteData/getInt64_A02_t01: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/ByteData/getInt64_A02_t02: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/ByteData/getUint64_A01_t01: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/ByteData/getUint64_A02_t01: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/ByteData/getUint64_A02_t02: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/ByteData/setInt64_A01_t01: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/ByteData/setInt64_A02_t01: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/ByteData/setInt64_A02_t02: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/ByteData/setUint64_A01_t01: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/ByteData/setUint64_A02_t01: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/ByteData/setUint64_A02_t02: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/Int64List/*: SkipByDesign # Int64List not supported on the web
|
||||
LibTest/typed_data/Uint64List/*: SkipByDesign # Uint64List not supported on the web
|
||||
|
||||
[ $compiler == dart2js && $runtime == chrome ]
|
||||
LibTest/html/Window/animationFrame_A01_t01: SkipByDesign # Issue #53985: requestAnimationFrame is not executed on Chrome inactive tabs
|
||||
co19_2/LibTest/html/IFrameElement/blur_A01_t01: SkipByDesign # 62% flaky, unexplained, passes consistently in co19 suite (just flakes in co19_2)
|
||||
co19_2/LibTest/html/IFrameElement/focus_A01_t01: SkipByDesign # 80% flaky, unexplained, passes consistently in co19 suite (just flakes in co19_2)
|
||||
|
||||
[ $compiler == dart2js && $runtime == d8 ]
|
||||
LibTest/html/*: SkipByDesign # d8 is not a browser
|
||||
|
||||
[ $compiler == dart2js && $runtime == d8 && $host_checked ]
|
||||
LibTest/collection/ListBase/ListBase_class_A01_t04: Slow, Pass
|
||||
LibTest/collection/ListBase/ListBase_class_A01_t05: Slow, Pass
|
||||
LibTest/collection/ListBase/ListBase_class_A01_t06: Slow, Pass
|
||||
LibTest/collection/ListMixin/ListMixin_class_A01_t04: Slow, Pass
|
||||
LibTest/collection/ListMixin/ListMixin_class_A01_t05: Slow, Pass
|
||||
LibTest/collection/ListMixin/ListMixin_class_A01_t06: Slow, Pass
|
||||
LibTest/core/List/List_class_A01_t05: Slow, Pass
|
||||
LibTest/core/List/List_class_A01_t06: Slow, Pass
|
||||
|
||||
[ $compiler == dart2js && $runtime == ie11 ]
|
||||
LibTest/collection/ListBase/ListBase_class_A01_t04: SkipSlow # slow babeljs transformation
|
||||
LibTest/collection/ListBase/ListBase_class_A01_t05: SkipSlow # slow babeljs transformation
|
||||
LibTest/collection/ListBase/ListBase_class_A01_t06: SkipSlow # slow babeljs transformation
|
||||
LibTest/collection/ListMixin/ListMixin_class_A01_t04: SkipSlow # slow babeljs transformation
|
||||
LibTest/collection/ListMixin/ListMixin_class_A01_t05: SkipSlow # slow babeljs transformation
|
||||
LibTest/collection/ListMixin/ListMixin_class_A01_t06: SkipSlow # slow babeljs transformation
|
||||
LibTest/core/List/List_class_A01_t04: SkipSlow # slow babeljs transformation
|
||||
LibTest/core/List/List_class_A01_t05: SkipSlow # slow babeljs transformation
|
||||
LibTest/core/List/List_class_A01_t06: SkipSlow # slow babeljs transformation
|
||||
|
||||
[ $compiler == dart2js && $runtime == safari ]
|
||||
LibTest/html/Element/isContentEditable_A02_t01: Skip # evades flake detection https://github.com/dart-lang/sdk/issues/50718
|
||||
LibTest/html/IFrameElement/isContentEditable_A01_t01: Skip # evades flake detection https://github.com/dart-lang/sdk/issues/50718
|
|
@ -1,129 +0,0 @@
|
|||
# Copyright (c) 2019, 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.
|
||||
|
||||
[ $compiler == ddc ]
|
||||
Language/Classes/Constructors/Generative_Constructors/formal_parameter_t07: SkipSlow
|
||||
Language/Classes/Constructors/Generative_Constructors/fresh_instance_t01: SkipSlow
|
||||
Language/Classes/Constructors/Generative_Constructors/implicit_superinitializer_t01: SkipSlow
|
||||
Language/Classes/Constructors/Generative_Constructors/implicit_superinitializer_t02: SkipSlow
|
||||
Language/Classes/Constructors/Generative_Constructors/initializers_t01: SkipSlow
|
||||
Language/Classes/Constructors/Generative_Constructors/initializers_t15: SkipSlow
|
||||
Language/Classes/Constructors/Generative_Constructors/initializing_formals_execution_t01: SkipSlow
|
||||
Language/Classes/Constructors/Generative_Constructors/initializing_this_t01: SkipSlow
|
||||
Language/Classes/Constructors/Generative_Constructors/redirection_t01: SkipSlow
|
||||
Language/Classes/Constructors/Generative_Constructors/syntax_t01: SkipSlow
|
||||
Language/Classes/Constructors/implicit_constructor_t01: SkipSlow
|
||||
Language/Classes/Constructors/implicit_constructor_t02: SkipSlow
|
||||
Language/Classes/Constructors/name_t01: SkipSlow
|
||||
Language/Classes/Constructors/name_t02: SkipSlow
|
||||
Language/Classes/Constructors/name_t03: SkipSlow
|
||||
Language/Classes/Getters/instance_getter_t01: SkipSlow
|
||||
Language/Classes/Getters/instance_getter_t02: SkipSlow
|
||||
Language/Classes/Getters/instance_getter_t03: SkipSlow
|
||||
Language/Classes/Getters/instance_getter_t04: SkipSlow
|
||||
Language/Classes/Getters/instance_getter_t05: SkipSlow
|
||||
Language/Classes/Getters/instance_getter_t06: SkipSlow
|
||||
Language/Classes/Getters/override_t04: SkipSlow
|
||||
Language/Classes/Getters/return_type_t01: SkipSlow
|
||||
Language/Classes/Getters/static_t01/none: SkipSlow
|
||||
Language/Classes/Getters/static_t02: SkipSlow
|
||||
Language/Classes/Getters/syntax_t01: SkipSlow
|
||||
Language/Classes/Getters/void_return_type_t01: SkipSlow
|
||||
Language/Classes/Instance_Methods/Operators/allowed_names_t01: SkipSlow
|
||||
Language/Classes/Instance_Methods/Operators/arity_0_or_1_t01: SkipSlow
|
||||
Language/Classes/Instance_Methods/Operators/arity_0_t01: SkipSlow
|
||||
Language/Classes/Instance_Methods/Operators/syntax_t01: SkipSlow
|
||||
Language/Classes/Instance_Methods/Operators/syntax_t03: SkipSlow
|
||||
Language/Classes/Instance_Methods/override_named_parameters_t03: SkipSlow
|
||||
Language/Classes/Instance_Methods/override_named_parameters_t04: SkipSlow
|
||||
Language/Classes/Instance_Methods/override_named_parameters_t06: SkipSlow
|
||||
Language/Classes/Instance_Methods/override_subtype_t05: SkipSlow
|
||||
Language/Classes/Instance_Methods/override_subtype_t06: SkipSlow
|
||||
Language/Classes/Instance_Methods/same_name_static_member_in_superclass_t01: SkipSlow
|
||||
Language/Classes/Instance_Methods/same_name_static_member_in_superclass_t02: SkipSlow
|
||||
Language/Classes/Instance_Methods/same_name_static_member_in_superclass_t04: SkipSlow
|
||||
Language/Classes/Instance_Methods/same_name_static_member_in_superclass_t05: SkipSlow
|
||||
Language/Classes/Instance_Methods/same_name_static_member_in_superclass_t06: SkipSlow
|
||||
Language/Classes/Instance_Methods/same_name_static_member_in_superclass_t07: SkipSlow
|
||||
Language/Classes/Instance_Methods/same_name_static_member_in_superclass_t08: SkipSlow
|
||||
Language/Classes/Instance_Methods/same_name_static_member_in_superclass_t09: SkipSlow
|
||||
Language/Classes/Instance_Variables/definition_t01: SkipSlow
|
||||
Language/Classes/Instance_Variables/definition_t02: SkipSlow
|
||||
Language/Classes/Instance_Variables/definition_t04: SkipSlow
|
||||
Language/Classes/Setters/instance_setter_t01: SkipSlow
|
||||
Language/Expressions/Constants/integer_size_t03: SkipByDesign # uses integer literal not representable as JavaScript number
|
||||
Language/Expressions/Constants/integer_size_t04: SkipByDesign # uses integer literal not representable as JavaScript number
|
||||
Language/Expressions/Constants/literal_number_t01: SkipByDesign # uses integer literal not representable as JavaScript number
|
||||
Language/Expressions/Constants/math_operators_t01: SkipByDesign # uses integer literal not representable as JavaScript number
|
||||
Language/Expressions/Constants/math_operators_t06: SkipByDesign # uses integer literal not representable as JavaScript number
|
||||
Language/Expressions/Numbers/integer_size_t03: SkipByDesign # uses integer literal not representable as JavaScript number
|
||||
Language/Expressions/Numbers/static_type_of_int_t01: SkipByDesign # uses integer literal not representable as JavaScript number
|
||||
Language/Expressions/Numbers/syntax_t06: SkipByDesign # uses integer literal not representable as JavaScript number
|
||||
Language/Expressions/Numbers/syntax_t09: SkipByDesign # uses integer literal not representable as JavaScript number
|
||||
Language/Expressions/Object_Identity/object_t02: SkipByDesign # https://github.com/dart-lang/sdk/issues/42222#issuecomment-640431711
|
||||
Language/Expressions/Spawning_an_Isolate/new_isolate_t01: SkipByDesign # dart:isolate not supported.
|
||||
Language/Functions/External_Functions/not_connected_to_a_body_t01: SkipByDesign # External variables are not supported
|
||||
Language/Libraries_and_Scripts/Scripts/top_level_main_t01: SkipByDesign # Uses dart:io.
|
||||
Language/Libraries_and_Scripts/Scripts/top_level_main_t06: SkipByDesign # Uses dart:io.
|
||||
Language/Libraries_and_Scripts/Scripts/top_level_syntax_t01: SkipByDesign # External variables are not supported
|
||||
Language/Libraries_and_Scripts/top_level_syntax_t01: SkipByDesign # External variables are not supported
|
||||
Language/Reference/Operator_Precedence/precedence_15_unary_prefix_t08: SkipByDesign # binary '~' produces different results in JavaScript and Dart
|
||||
Language/Types/Interface_Types/subtype_t27: SkipSlow
|
||||
Language/Types/Interface_Types/subtype_t28: SkipSlow
|
||||
LibTest/core/DateTime/DateTime.fromMicrosecondsSinceEpoch_A01_t01: SkipByDesign # microseconds are not supported in JavaScript
|
||||
LibTest/core/DateTime/microsecond_A01_t01: SkipByDesign # microseconds are not supported in JavaScript
|
||||
LibTest/core/DateTime/microsecondsSinceEpoch_A01_t01: SkipByDesign # microseconds are not supported in JavaScript
|
||||
LibTest/core/DateTime/to8601String_A01_t01: SkipByDesign # microseconds are not supported in JavaScript
|
||||
LibTest/core/DateTime/to8601String_A01_t02: SkipByDesign # microseconds are not supported in JavaScript
|
||||
LibTest/core/DateTime/to8601String_A01_t03: SkipByDesign # microseconds are not supported in JavaScript
|
||||
LibTest/core/int/operator_remainder_A01_t03: SkipByDesign # Division by zero is not an error in JavaScript
|
||||
LibTest/core/int/operator_truncating_division_A01_t02: SkipByDesign # Division by zero is not an error in JavaScript
|
||||
LibTest/core/int/parse_A01_t02: SkipByDesign # big integers cannot be represented in JavaScript
|
||||
LibTest/core/int/remainder_A01_t03: SkipByDesign # Division by zero is not an error in JavaScript
|
||||
LibTest/html/CanvasRenderingContext2D/addEventListener_A01_t03: SkipSlow
|
||||
LibTest/html/Element/blur_A01_t01: SkipSlow
|
||||
LibTest/html/Element/focus_A01_t01: SkipSlow
|
||||
LibTest/html/Element/loadEvent_A01_t01: SkipSlow
|
||||
LibTest/html/Element/mouseWheelEvent_A01_t01: SkipSlow
|
||||
LibTest/html/Element/onLoad_A01_t01: SkipSlow
|
||||
LibTest/html/Element/onMouseWheel_A01_t01: SkipSlow
|
||||
LibTest/html/Element/onTransitionEnd_A01_t01: SkipSlow
|
||||
LibTest/html/Element/transitionEndEvent_A01_t01: SkipSlow
|
||||
LibTest/html/HttpRequest/onError_A01_t02: SkipSlow
|
||||
LibTest/html/HttpRequest/responseText_A01_t02: SkipSlow
|
||||
LibTest/html/HttpRequestUpload/onError_A01_t02: SkipSlow
|
||||
LibTest/html/HttpRequestUpload/onLoadEnd_A01_t01: SkipSlow
|
||||
LibTest/html/HttpRequestUpload/onLoadStart_A01_t01: SkipSlow
|
||||
LibTest/html/HttpRequestUpload/onLoad_A01_t01: SkipSlow
|
||||
LibTest/html/IFrameElement/blur_A01_t01: SkipSlow
|
||||
LibTest/html/IFrameElement/enteredView_A01_t01: SkipSlow
|
||||
LibTest/html/IFrameElement/focus_A01_t01: SkipSlow
|
||||
LibTest/html/IFrameElement/onMouseWheel_A01_t01: SkipSlow
|
||||
LibTest/html/IFrameElement/onTransitionEnd_A01_t01: SkipSlow
|
||||
LibTest/io/*: SkipByDesign # dart:io not supported
|
||||
LibTest/isolate/*: SkipByDesign # dart:isolate not supported
|
||||
LibTest/mirrors/*: SkipByDesign # dart:mirrors not supported
|
||||
LibTest/typed_data/ByteBuffer/asInt64List_A01_t01: SkipByDesign # Int64List not supported on the web
|
||||
LibTest/typed_data/ByteBuffer/asInt64List_A02_t01: SkipByDesign # Int64List not supported on the web
|
||||
LibTest/typed_data/ByteBuffer/asInt64List_A03_t01: SkipByDesign # Int64List not supported on the web
|
||||
LibTest/typed_data/ByteBuffer/asUint64List_A01_t01: SkipByDesign # UInt64List not supported on the web
|
||||
LibTest/typed_data/ByteBuffer/asUint64List_A02_t01: SkipByDesign # UInt64List not supported on the web
|
||||
LibTest/typed_data/ByteBuffer/asUint64List_A03_t01: SkipByDesign # UInt64List not supported on the web
|
||||
LibTest/typed_data/ByteData/getInt64_A01_t01: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/ByteData/getInt64_A02_t01: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/ByteData/getInt64_A02_t02: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/ByteData/getUint64_A01_t01: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/ByteData/getUint64_A02_t01: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/ByteData/getUint64_A02_t02: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/ByteData/setInt64_A01_t01: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/ByteData/setInt64_A02_t01: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/ByteData/setInt64_A02_t02: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/ByteData/setUint64_A01_t01: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/ByteData/setUint64_A02_t01: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/ByteData/setUint64_A02_t02: SkipByDesign # 64-bit int not supported on the web
|
||||
LibTest/typed_data/Int64List/*: SkipByDesign # Int64List not supported on the web
|
||||
LibTest/typed_data/Uint64List/*: SkipByDesign # Uint64List not supported on the web
|
||||
|
||||
[ $compiler == ddc && $runtime == chrome ]
|
||||
LibTest/html/Window/animationFrame_A01_t01: SkipByDesign # Issue #53985: requestAnimationFrame is not executed on Chrome inactive tabs
|
|
@ -1,44 +0,0 @@
|
|||
# Copyright (c) 2018, 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.
|
||||
|
||||
[ $compiler == fasta ]
|
||||
LanguageFeatures/Instantiate-to-bound/typedef/static/typedef_l2_06_t04: SkipByDesign # Won't fix. See https://github.com/dart-lang/sdk/issues/46288
|
||||
|
||||
[ $runtime == dart_precompiled ]
|
||||
LibTest/mirrors/*: SkipByDesign # dart:mirrors is not supported
|
||||
|
||||
[ $runtime == vm ]
|
||||
LibTest/collection/ListBase/ListBase_class_A01_t02: Slow, Pass # Does many calls
|
||||
LibTest/collection/ListMixin/ListMixin_class_A01_t02: Slow, Pass # Does many calls
|
||||
LibTest/core/List/List_class_A01_t02: Slow, Pass # Does many calls
|
||||
LibTest/io/Stdout/add_A02_t03: SkipByDesign # Issue dart-lang/co19/issues/1509
|
||||
LibTest/io/Stdout/add_A02_t04: SkipByDesign
|
||||
LibTest/io/Stdout/add_A02_t05: SkipByDesign
|
||||
LibTest/io/Stdout/add_A02_t06: SkipByDesign
|
||||
LibTest/io/Stdout/add_A02_t07: SkipByDesign
|
||||
LibTest/io/Stdout/add_A02_t08: SkipByDesign
|
||||
LibTest/io/Stdout/add_A02_t09: SkipByDesign
|
||||
LibTest/io/Stdout/writeCharCode_A01_t03: SkipByDesign
|
||||
LibTest/io/Stdout/write_A01_t04: SkipByDesign
|
||||
LibTest/io/Stdout/write_A01_t05: SkipByDesign
|
||||
LibTest/io/exit/exit_A04_t01: SkipByDesign
|
||||
|
||||
[ $compiler == dartk && $runtime == vm && $system == macos ]
|
||||
LibTest/collection/ListBase/ListBase_class_A01_t02: Slow, Pass
|
||||
LibTest/collection/ListBase/ListBase_class_A01_t03: Slow, Pass
|
||||
LibTest/collection/ListMixin/ListMixin_class_A01_t02: Slow, Pass
|
||||
LibTest/collection/ListMixin/ListMixin_class_A01_t03: Slow, Pass
|
||||
LibTest/core/List/List_class_A01_t02: Slow, Pass
|
||||
LibTest/core/List/List_class_A01_t03: Slow, Pass
|
||||
|
||||
[ $runtime == dart_precompiled && $simulator ]
|
||||
LibTest/collection/ListBase/ListBase_class_A01_t01: SkipSlow # Issue 43036
|
||||
LibTest/collection/ListMixin/ListMixin_class_A01_t01: SkipSlow # Issue 43036
|
||||
|
||||
# It makes no sense to run any test that uses spawnURI under the simulator
|
||||
# as that would involve running CFE (the front end) in simulator mode
|
||||
# to compile the URI file specified in spawnURI code.
|
||||
# These Isolate tests that use spawnURI are hence skipped on purpose.
|
||||
[ $runtime == dart_precompiled || $runtime == vm && $simulator ]
|
||||
LibTest/isolate/Isolate/spawnUri*: Skip
|
|
@ -1,35 +0,0 @@
|
|||
# Copyright (c) 2018, 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.
|
||||
|
||||
[ $system == windows ]
|
||||
LibTest/io/ProcessResult/exitCode_A01_t02: Skip # Issue 32138
|
||||
LibTest/io/Stdin/readByteSync_A01_t01: Skip # Issue 32138
|
||||
LibTest/io/Stdin/readByteSync_A01_t02: Skip # Issue 32138
|
||||
|
||||
[ $simulator ]
|
||||
LibTest/collection/ListBase/ListBase_class_A01_t01: SkipSlow # Very slow on sim* architectures.
|
||||
LibTest/collection/ListBase/ListBase_class_A01_t04: SkipSlow # Very slow on sim* architectures.
|
||||
LibTest/collection/ListBase/ListBase_class_A01_t05: SkipSlow # Very slow on sim* architectures.
|
||||
LibTest/collection/ListBase/ListBase_class_A01_t06: SkipSlow # Very slow on sim* architectures.
|
||||
LibTest/collection/ListMixin/ListMixin_class_A01_t01: SkipSlow # Very slow on sim* architectures.
|
||||
LibTest/collection/ListMixin/ListMixin_class_A01_t04: SkipSlow # Very slow on sim* architectures.
|
||||
LibTest/collection/ListMixin/ListMixin_class_A01_t05: SkipSlow # Very slow on sim* architectures.
|
||||
LibTest/collection/ListMixin/ListMixin_class_A01_t06: SkipSlow # Very slow on sim* architectures.
|
||||
|
||||
[ $mode == debug && $runtime == dart_precompiled ]
|
||||
LibTest/collection/ListBase/ListBase_class_A01_t03: SkipSlow # Very slow compilation in debug mode.
|
||||
LibTest/collection/ListBase/ListBase_class_A01_t04: SkipSlow # Very slow compilation in debug mode.
|
||||
LibTest/collection/ListBase/ListBase_class_A01_t05: SkipSlow # Very slow compilation in debug mode.
|
||||
LibTest/collection/ListBase/ListBase_class_A01_t06: SkipSlow # Very slow compilation in debug mode.
|
||||
LibTest/collection/ListMixin/ListMixin_class_A01_t03: SkipSlow # Very slow compilation in debug mode.
|
||||
LibTest/collection/ListMixin/ListMixin_class_A01_t04: SkipSlow # Very slow compilation in debug mode.
|
||||
LibTest/collection/ListMixin/ListMixin_class_A01_t05: SkipSlow # Very slow compilation in debug mode.
|
||||
LibTest/collection/ListMixin/ListMixin_class_A01_t06: SkipSlow # Very slow compilation in debug mode.
|
||||
|
||||
[ $runtime == dart_precompiled && $simulator ]
|
||||
LibTest/async/Stream/Stream.periodic_all_t02: Skip # Issue 42898
|
||||
|
||||
[ $compiler == fasta || $runtime == dart_precompiled || $runtime == vm ]
|
||||
Language/Expressions/Numbers/syntax_t34: SkipByDesign # expects integer literal error that only occurs in JS
|
||||
LibTest/html/*: SkipByDesign # dart:html not supported on VM.
|
|
@ -1,39 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# Uploads a new version of the co19_2 CIPD package.
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
if [ ! -e tests/co19_2 ]; then
|
||||
echo "$0: error: Run this script at the root of the Dart SDK" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find the latest co19 commit.
|
||||
rm -rf tests/co19_2/src.git
|
||||
git clone https://dart.googlesource.com/co19 tests/co19_2/src.git
|
||||
CO19=tests/co19_2/src.git
|
||||
OLD=$(gclient getdep --var=co19_2_rev)
|
||||
NEW=$(cd $CO19 && git fetch origin && git rev-parse origin/pre-nnbd)
|
||||
|
||||
git fetch origin
|
||||
git branch cl-co19-roll-co19-to-$NEW origin/main
|
||||
git checkout cl-co19-roll-co19-to-$NEW
|
||||
|
||||
# Update DEPS:
|
||||
gclient setdep --var=co19_2_rev=$NEW
|
||||
|
||||
# Make a nice commit. Don't include the '#' character to avoid referencing Dart
|
||||
# SDK issues.
|
||||
git commit DEPS -m \
|
||||
"$(printf "[co19] Roll co19_2 to $NEW\n\n" \
|
||||
&& cd $CO19 \
|
||||
&& git log --date='format:%Y-%m-%d' --pretty='format:%ad %ae %s' $OLD..$NEW \
|
||||
| sed 's/\#/dart-lang\/co19\#/g')"
|
||||
|
||||
rm -rf tests/co19_2/src.git
|
||||
|
||||
GIT_EDITOR=true git cl upload
|
||||
ISSUE=$(git config --get branch.cl-co19-roll-co19-to-$NEW.gerritissue)
|
||||
|
||||
git cl web
|
|
@ -1,101 +0,0 @@
|
|||
// Copyright (c) 2012, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
// VMOptions=
|
||||
// VMOptions=--dwarf_stack_traces --no-retain_function_objects --no-retain_code_objects
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
apply(Function function, List positional, Map<Symbol, dynamic> named) {
|
||||
return Function.apply(function, positional, named);
|
||||
}
|
||||
|
||||
void throwsNSME(
|
||||
Function function, List positional, Map<Symbol, dynamic> named) {
|
||||
Expect.throwsNoSuchMethodError(() => apply(function, positional, named));
|
||||
}
|
||||
|
||||
main() {
|
||||
var c1 = () => 'c1';
|
||||
var c2 = (a) => 'c2 $a';
|
||||
var c3 = ([a = 1]) => 'c3 $a';
|
||||
var c4 = ({a: 1}) => 'c4 $a';
|
||||
var c5 = ({a: 1, b: 2}) => 'c5 $a $b';
|
||||
var c6 = ({b: 1, a: 2}) => 'c6 $a $b';
|
||||
var c7 = (x, {b: 1, a: 2}) => 'c7 $x $a $b';
|
||||
var c8 = (x, y, [a = 2, b = 3]) => 'c8 $x $y $a $b';
|
||||
|
||||
Expect.equals('c1', apply(c1, null, null));
|
||||
Expect.equals('c1', apply(c1, [], null));
|
||||
Expect.equals('c1', apply(c1, [], {}));
|
||||
Expect.equals('c1', apply(c1, null, {}));
|
||||
throwsNSME(c1, [1], null);
|
||||
throwsNSME(c1, [1], {#a: 2});
|
||||
throwsNSME(c1, null, {#a: 2});
|
||||
|
||||
Expect.equals('c2 1', apply(c2, [1], null));
|
||||
Expect.equals('c2 1', apply(c2, [1], {}));
|
||||
throwsNSME(c2, null, null);
|
||||
throwsNSME(c2, [], null);
|
||||
throwsNSME(c2, null, {});
|
||||
throwsNSME(c2, null, {#a: 1});
|
||||
throwsNSME(c2, [2], {#a: 1});
|
||||
|
||||
Expect.equals('c3 1', apply(c3, null, null));
|
||||
Expect.equals('c3 1', apply(c3, [], null));
|
||||
Expect.equals('c3 2', apply(c3, [2], {}));
|
||||
throwsNSME(c3, [1, 2], null);
|
||||
throwsNSME(c3, null, {#a: 1});
|
||||
|
||||
Expect.equals('c4 1', apply(c4, [], null));
|
||||
Expect.equals('c4 2', apply(c4, [], {#a: 2}));
|
||||
Expect.equals('c4 1', apply(c4, null, null));
|
||||
Expect.equals('c4 1', apply(c4, [], {}));
|
||||
throwsNSME(c4, [1], {#a: 1});
|
||||
throwsNSME(c4, [1], {});
|
||||
throwsNSME(c4, [], {#a: 1, #b: 2});
|
||||
|
||||
Expect.equals('c5 1 2', apply(c5, [], null));
|
||||
Expect.equals('c5 3 2', apply(c5, [], {#a: 3}));
|
||||
Expect.equals('c5 1 2', apply(c5, null, null));
|
||||
Expect.equals('c5 1 2', apply(c5, [], {}));
|
||||
Expect.equals('c5 3 4', apply(c5, [], {#a: 3, #b: 4}));
|
||||
Expect.equals('c5 4 3', apply(c5, [], {#b: 3, #a: 4}));
|
||||
Expect.equals('c5 1 3', apply(c5, [], {#b: 3}));
|
||||
throwsNSME(c5, [1], {#a: 1});
|
||||
throwsNSME(c5, [1], {});
|
||||
throwsNSME(c5, [], {#a: 1, #b: 2, #c: 3});
|
||||
|
||||
Expect.equals('c6 2 1', apply(c6, [], null));
|
||||
Expect.equals('c6 3 1', apply(c6, [], {#a: 3}));
|
||||
Expect.equals('c6 2 1', apply(c6, null, null));
|
||||
Expect.equals('c6 2 1', apply(c6, [], {}));
|
||||
Expect.equals('c6 3 4', apply(c6, [], {#a: 3, #b: 4}));
|
||||
Expect.equals('c6 4 3', apply(c6, [], {#b: 3, #a: 4}));
|
||||
Expect.equals('c6 2 3', apply(c6, [], {#b: 3}));
|
||||
throwsNSME(c6, [1], {#a: 1});
|
||||
throwsNSME(c6, [1], {});
|
||||
throwsNSME(c6, [], {#a: 1, #b: 2, #c: 3});
|
||||
|
||||
Expect.equals('c7 7 2 1', apply(c7, [7], null));
|
||||
Expect.equals('c7 7 3 1', apply(c7, [7], {#a: 3}));
|
||||
Expect.equals('c7 7 2 1', apply(c7, [7], {}));
|
||||
Expect.equals('c7 7 3 4', apply(c7, [7], {#a: 3, #b: 4}));
|
||||
Expect.equals('c7 7 4 3', apply(c7, [7], {#b: 3, #a: 4}));
|
||||
Expect.equals('c7 7 2 3', apply(c7, [7], {#b: 3}));
|
||||
throwsNSME(c7, [], {#a: 1});
|
||||
throwsNSME(c7, [], {});
|
||||
throwsNSME(c7, [7], {#a: 1, #b: 2, #c: 3});
|
||||
|
||||
Expect.equals('c8 7 8 2 3', apply(c8, [7, 8], null));
|
||||
Expect.equals('c8 7 8 2 3', apply(c8, [7, 8], {}));
|
||||
Expect.equals('c8 7 8 3 3', apply(c8, [7, 8, 3], null));
|
||||
Expect.equals('c8 7 8 3 4', apply(c8, [7, 8, 3, 4], null));
|
||||
throwsNSME(c8, [], null);
|
||||
throwsNSME(c8, [], {});
|
||||
throwsNSME(c8, [1], null);
|
||||
throwsNSME(c8, [7, 8, 9, 10, 11], null);
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
// Test [Function.apply] on user-defined classes that implement [noSuchMethod].
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
class F {
|
||||
call([p1]) => "call";
|
||||
noSuchMethod(Invocation invocation) => "NSM";
|
||||
}
|
||||
|
||||
class G {
|
||||
call() => '42';
|
||||
noSuchMethod(Invocation invocation) => invocation;
|
||||
}
|
||||
|
||||
class H {
|
||||
call(required, {a}) => required + a;
|
||||
}
|
||||
|
||||
main() {
|
||||
Expect.equals('call', Function.apply(new F(), []));
|
||||
Expect.equals('call', Function.apply(new F(), [1]));
|
||||
Expect.throwsNoSuchMethodError(() => Function.apply(new F(), [1, 2]));
|
||||
Expect.throwsNoSuchMethodError(() => Function.apply(new F(), [1, 2, 3]));
|
||||
|
||||
Expect.throwsNoSuchMethodError(() => Function.apply(new G(), [1], {#a: 42}));
|
||||
|
||||
// Test that [i] can be used to hit an existing method.
|
||||
Expect.equals(43, new H().call(1, a: 42));
|
||||
Expect.equals(43, Function.apply(new H(), [1], {#a: 42}));
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
// Testing Function.apply calls work correctly for arities that are not
|
||||
// otherwise present in the program (and thus might not have stubs
|
||||
// generated).
|
||||
|
||||
class A {
|
||||
foo(x, [y, z, a, b, c, d = 99, e, f, g, h, i, j]) => "$x $d";
|
||||
}
|
||||
|
||||
main() {
|
||||
var a = new A();
|
||||
var clos = a.foo;
|
||||
Expect.equals(Function.apply(clos, ["well"]), "well 99");
|
||||
Expect.equals(Function.apply(clos, ["well", 0, 2, 4, 3, 6, 9, 10]), "well 9");
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
// Copyright (c) 2016, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
// Testing that, when compiled to JS, Function.apply works correctly for
|
||||
// functions with that will be invoked directly vs using .apply().
|
||||
|
||||
class A {
|
||||
foo([a = 10, b = 20, c = 30, d = 40, e = 50]) => "$a $b $c $d $e";
|
||||
}
|
||||
|
||||
main() {
|
||||
var a = new A();
|
||||
var clos = a.foo;
|
||||
Expect.equals(Function.apply(clos, []), "10 20 30 40 50");
|
||||
Expect.equals(Function.apply(clos, [11]), "11 20 30 40 50");
|
||||
Expect.equals(Function.apply(clos, [11, 21]), "11 21 30 40 50");
|
||||
Expect.equals(Function.apply(clos, [11, 21, 31]), "11 21 31 40 50");
|
||||
Expect.equals(Function.apply(clos, [11, 21, 31, 41]), "11 21 31 41 50");
|
||||
Expect.equals(Function.apply(clos, [11, 21, 31, 41, 51]), "11 21 31 41 51");
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
// Copyright (c) 2021, 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.
|
||||
|
||||
// @dart=2.9
|
||||
|
||||
// Test that the List of positional arguments to [Function.apply] is not
|
||||
// modified.
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
class A {
|
||||
foo([
|
||||
a = 10,
|
||||
b = 20,
|
||||
c = 30,
|
||||
d = 40,
|
||||
e = 50,
|
||||
f = 60,
|
||||
g = 70,
|
||||
h = 80,
|
||||
i = 90,
|
||||
]) =>
|
||||
'$a $b $c $d $e $f $g $h $i';
|
||||
}
|
||||
|
||||
String static1(a, b, {c = 30, d = 40}) => '$a $b $c $d';
|
||||
|
||||
void test(String expected, Function function, List positional,
|
||||
[Map<Symbol, dynamic> named = null]) {
|
||||
final original = List.of(positional);
|
||||
|
||||
Expect.equals(expected, Function.apply(function, positional, named));
|
||||
Expect.listEquals(original, positional);
|
||||
|
||||
// Test again so there are multiple call sites for `Function.apply`.
|
||||
Expect.equals(expected, Function.apply(function, positional, named));
|
||||
Expect.listEquals(original, positional);
|
||||
}
|
||||
|
||||
main() {
|
||||
var a = A();
|
||||
|
||||
test('10 20 30 40 50 60 70 80 90', a.foo, []);
|
||||
test('11 20 30 40 50 60 70 80 90', a.foo, [11]);
|
||||
test('11 22 30 40 50 60 70 80 90', a.foo, [11, 22]);
|
||||
test('11 22 33 40 50 60 70 80 90', a.foo, [11, 22, 33]);
|
||||
test('11 22 33 44 50 60 70 80 90', a.foo, [11, 22, 33, 44]);
|
||||
test('11 22 33 44 55 60 70 80 90', a.foo, [11, 22, 33, 44, 55]);
|
||||
test('11 22 33 44 55 66 70 80 90', a.foo, [11, 22, 33, 44, 55, 66]);
|
||||
test('11 22 33 44 55 66 77 80 90', a.foo, [11, 22, 33, 44, 55, 66, 77]);
|
||||
test('11 22 33 44 55 66 77 88 90', a.foo, [11, 22, 33, 44, 55, 66, 77, 88]);
|
||||
test('11 22 33 44 55 66 77 88 99', a.foo,
|
||||
[11, 22, 33, 44, 55, 66, 77, 88, 99]);
|
||||
|
||||
// Some unmodifiable Lists. An attempt to modify the argument would fail.
|
||||
test('11 22 33 44 55 66 77 80 90', a.foo, const [11, 22, 33, 44, 55, 66, 77]);
|
||||
test('65 66 67 68 69 70 71 80 90', a.foo, 'ABCDEFG'.codeUnits);
|
||||
|
||||
test('11 22 30 40', static1, [11, 22]);
|
||||
test('11 22 30 40', static1, [11, 22], {});
|
||||
test('11 22 33 40', static1, [11, 22], {#c: 33});
|
||||
test('11 22 30 44', static1, [11, 22], {#d: 44});
|
||||
test('11 22 66 55', static1, [11, 22], {#d: 55, #c: 66});
|
||||
|
||||
test('11 22 88 77', static1, const [11, 22], {#d: 77, #c: 88});
|
||||
test('65 66 11 22', static1, 'AB'.codeUnits, {#d: 22, #c: 11});
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
// Copyright (c) 2018, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import "symbol_map_helper.dart";
|
||||
|
||||
// Testing Function.apply calls correctly with generic type arguments.
|
||||
// This test is not testing error handling, only that correct parameters
|
||||
// cause a correct call.
|
||||
|
||||
test0<T extends num>(T i, T j, {T a}) => i + j + a;
|
||||
|
||||
main() {
|
||||
test(res, func, list, map) {
|
||||
map = symbolMapToStringMap(map);
|
||||
Expect.equals(res, Function.apply(func, list, map));
|
||||
}
|
||||
|
||||
test(42, test0, [10, 15], {"a": 17});
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
// Copyright (c) 2012, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import "symbol_map_helper.dart";
|
||||
|
||||
// Testing Function.apply calls correctly.
|
||||
// This test is not testing error handling, only that correct parameters
|
||||
// cause a correct call.
|
||||
|
||||
int test0() => 42;
|
||||
int test0a({int a}) => 37 + a;
|
||||
int test1(int i) => i + 1;
|
||||
int test1a(int i, {int a}) => i + a;
|
||||
int test2(int i, int j) => i + j;
|
||||
int test2a(int i, int j, {int a}) => i + j + a;
|
||||
|
||||
class C {
|
||||
int x = 10;
|
||||
int foo(y) => this.x + y;
|
||||
}
|
||||
|
||||
class Callable {
|
||||
int call(int x, int y) => x + y;
|
||||
}
|
||||
|
||||
@pragma('dart2js:noInline')
|
||||
@pragma('dart2js:assumeDynamic')
|
||||
confuse(x) => x;
|
||||
|
||||
main() {
|
||||
testMap(res, func, map) {
|
||||
Expect.equals(res, Function.apply(func, null, map));
|
||||
Expect.equals(res, Function.apply(func, [], map));
|
||||
}
|
||||
|
||||
testList(res, func, list) {
|
||||
Expect.equals(res, Function.apply(func, list));
|
||||
Expect.equals(res, Function.apply(func, list, null));
|
||||
Expect.equals(res, Function.apply(func, list, new Map<Symbol, dynamic>()));
|
||||
}
|
||||
|
||||
testListTyped(res, Function func, list) => testList(res, func, list);
|
||||
|
||||
test(res, func, list, map) {
|
||||
Expect.equals(res, Function.apply(func, list, map));
|
||||
}
|
||||
|
||||
testList(42, test0, null);
|
||||
testList(42, test0, []);
|
||||
testMap(42, test0a, {#a: 5});
|
||||
testList(42, test1, [41]);
|
||||
test(42, test1a, [20], {#a: 22});
|
||||
testList(42, test2, [20, 22]);
|
||||
test(42, test2a, [10, 15], {#a: 17});
|
||||
|
||||
// Test that "this" is correct when calling closurized functions.
|
||||
var cfoo = new C().foo;
|
||||
testList(42, cfoo, [32]);
|
||||
|
||||
// Test that apply works even with a different name.
|
||||
var app = confuse(Function.apply);
|
||||
Expect.equals(42, app(test2, [22, 20]));
|
||||
|
||||
// Test that apply can itself be applied.
|
||||
Expect.equals(
|
||||
42,
|
||||
Function.apply(Function.apply, [
|
||||
test2,
|
||||
[17, 25]
|
||||
]));
|
||||
|
||||
// Test that apply works on callable objects when it is passed to a method
|
||||
// that expects Function (and not dynamic).
|
||||
if (dart2jsProductionMode) {
|
||||
testList(42, new Callable(), [13, 29]);
|
||||
} else {
|
||||
Expect.throws(() => testList(42, new Callable(), [13, 29]));
|
||||
}
|
||||
|
||||
testListTyped(42, new Callable(), [13, 29]);
|
||||
}
|
|
@ -1,142 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
// Testing Bigints with and without intrinsics.
|
||||
// VMOptions=--intrinsify --no-enable-asserts
|
||||
// VMOptions=--intrinsify --enable-asserts
|
||||
// VMOptions=--no-intrinsify --enable-asserts
|
||||
// VMOptions=--no-intrinsify --no-enable-asserts
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
expectSum(aString, bString, expectedString) {
|
||||
BigInt a = BigInt.parse(aString, radix: 16);
|
||||
BigInt b = BigInt.parse(bString, radix: 16);
|
||||
BigInt expected = BigInt.parse(expectedString, radix: 16);
|
||||
BigInt actual = a + b;
|
||||
String actualString = actual.toRadixString(16);
|
||||
print("$aString + $bString");
|
||||
print(" = $actualString (expected $expectedString)");
|
||||
Expect.equals(expected, actual);
|
||||
}
|
||||
|
||||
main() {
|
||||
expectSum(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"1ad478de9e340aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectSum(
|
||||
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"1ad478de9e340aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectSum(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"a13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87c8de9e340aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectSum(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87bece9e340aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectSum(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"ac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87becaae340aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectSum(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87becaa3740aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectSum("d87becaa3701c97b31b5b8084f2b5b34e7857092", "1",
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857093");
|
||||
expectSum("d87becaa3701c97b31b5b8084f2b5b34e7857092", "0",
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
||||
|
||||
expectSum(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-3b04b6a8ac2e74f9845c182e303993e0efa8184");
|
||||
expectSum(
|
||||
"-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3b04b6a8ac2e74f9845c182e303993e0efa8184");
|
||||
expectSum(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"a13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87b4b6a8ac2e74f9845c182e303993e0efa8184");
|
||||
expectSum(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87bec6a8ac2e74f9845c182e303993e0efa8184");
|
||||
expectSum(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"ac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87beca98ac2e74f9845c182e303993e0efa8184");
|
||||
expectSum(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87becaa36c2e74f9845c182e303993e0efa8184");
|
||||
expectSum("-d87becaa3701c97b31b5b8084f2b5b34e7857092", "1",
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857091");
|
||||
expectSum("-d87becaa3701c97b31b5b8084f2b5b34e7857092", "0",
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
||||
|
||||
expectSum(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"3b04b6a8ac2e74f9845c182e303993e0efa8184");
|
||||
expectSum(
|
||||
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-3b04b6a8ac2e74f9845c182e303993e0efa8184");
|
||||
expectSum(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-a13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87b4b6a8ac2e74f9845c182e303993e0efa8184");
|
||||
expectSum(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-3fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87bec6a8ac2e74f9845c182e303993e0efa8184");
|
||||
expectSum(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-ac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87beca98ac2e74f9845c182e303993e0efa8184");
|
||||
expectSum(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87becaa36c2e74f9845c182e303993e0efa8184");
|
||||
expectSum("d87becaa3701c97b31b5b8084f2b5b34e7857092", "-1",
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857091");
|
||||
expectSum("d87becaa3701c97b31b5b8084f2b5b34e7857092", "-0",
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
||||
|
||||
expectSum(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-1ad478de9e340aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectSum(
|
||||
"-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-1ad478de9e340aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectSum(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-a13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87c8de9e340aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectSum(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-3fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87bece9e340aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectSum(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-ac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87becaae340aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectSum(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87becaa3740aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectSum("-d87becaa3701c97b31b5b8084f2b5b34e7857092", "-1",
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857093");
|
||||
expectSum("-d87becaa3701c97b31b5b8084f2b5b34e7857092", "-0",
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// Testing Bigints with and without intrinsics.
|
||||
// VMOptions=--intrinsify --no-enable-asserts
|
||||
// VMOptions=--intrinsify --enable-asserts
|
||||
// VMOptions=--no-intrinsify --enable-asserts
|
||||
// VMOptions=--no-intrinsify --no-enable-asserts
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
const debugPrint = bool.fromEnvironment('debugPrint');
|
||||
|
||||
void check(int length, BigInt base) {
|
||||
assert(length >= 5);
|
||||
assert(base > BigInt.zero);
|
||||
|
||||
// Check with slight adjustments. We choose -3..+3 so that the lowest bit in
|
||||
// the 2's-complement representation is both zero and one for both the
|
||||
// positive [n] and its negative complement [m] below.
|
||||
for (int delta = -3; delta <= 3; delta++) {
|
||||
BigInt n = base + BigInt.from(delta);
|
||||
assert(n >= BigInt.zero);
|
||||
|
||||
// Compute the bitLength by shifting the value into a small integer range
|
||||
// and adjust the `int.bitLength` value by the shift count.
|
||||
int shiftCount = length - 5;
|
||||
int shiftedN = (n >> shiftCount).toInt();
|
||||
int expectedLength = shiftCount + shiftedN.bitLength;
|
||||
|
||||
int nLength = n.bitLength;
|
||||
Expect.equals(expectedLength, nLength);
|
||||
|
||||
// Use identity `x.bitLength == (-x-1).bitLength` to check negative values.
|
||||
BigInt m = -n - BigInt.one;
|
||||
int mLength = m.bitLength;
|
||||
|
||||
if (debugPrint) {
|
||||
final printLength = length + 4;
|
||||
final nDigits =
|
||||
n.toUnsigned(printLength).toRadixString(2).padLeft(printLength);
|
||||
final mDigits = m.toUnsigned(printLength).toRadixString(2);
|
||||
print('$nDigits: $nLength');
|
||||
print('$mDigits: $mLength');
|
||||
}
|
||||
|
||||
Expect.equals(nLength, mLength);
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
// For small values, [BigInt.bitLength] should be the same as [int.bitLength].
|
||||
for (int i = 0; i <= 64; i++) {
|
||||
Expect.equals(i.bitLength, BigInt.from(i).bitLength);
|
||||
// Note: This is not quite redundant for `i==0` since on the web platform
|
||||
// `-i` is negative zero and not the same as `0-i`.
|
||||
Expect.equals((-i).bitLength, BigInt.from(-i).bitLength);
|
||||
}
|
||||
|
||||
// Test x.bitLength for a large variety of lengths.
|
||||
for (int length = 5; length <= 512; length++) {
|
||||
BigInt base = BigInt.one << (length - 1);
|
||||
Expect.equals(length, base.bitLength);
|
||||
|
||||
// Power of two.
|
||||
check(length, base);
|
||||
|
||||
// Two high bits set.
|
||||
check(length, base | base >> 1);
|
||||
|
||||
// Check for values with an additional bit set near a potential internal
|
||||
// digit boundary.
|
||||
for (int i1 = 16; i1 < length; i1 += 16) {
|
||||
for (int i2 = -1; i2 <= 1; i2++) {
|
||||
int i = i1 + i2;
|
||||
if (i < length - 1) {
|
||||
check(length, base | BigInt.one << (i - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,86 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
// Testing Bigints with and without intrinsics.
|
||||
// VMOptions=--intrinsify --no-enable-asserts
|
||||
// VMOptions=--intrinsify --enable-asserts
|
||||
// VMOptions=--no-intrinsify --enable-asserts
|
||||
// VMOptions=--no-intrinsify --no-enable-asserts
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
expectQuotient(aString, bString, expectedString) {
|
||||
BigInt a = BigInt.parse(aString, radix: 16);
|
||||
BigInt b = BigInt.parse(bString, radix: 16);
|
||||
BigInt expected = BigInt.parse(expectedString, radix: 16);
|
||||
BigInt actual = a ~/ b;
|
||||
String actualString = actual.toRadixString(16);
|
||||
print("$aString ~/ $bString");
|
||||
print(" = $actualString (expected $expectedString)");
|
||||
Expect.equals(expected, actual);
|
||||
}
|
||||
|
||||
main() {
|
||||
expectQuotient("d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e", "1");
|
||||
expectQuotient("d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092", "0");
|
||||
expectQuotient("d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"a13fac3ee22b996ff6856c27c1f6d88aef0e", "157b1");
|
||||
expectQuotient("d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3fac3ee22b996ff6856c27c1f6d88aef0e", "36662bd");
|
||||
expectQuotient("d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"ac3ee22b996ff6856c27c1f6d88aef0e", "141bfd63e");
|
||||
expectQuotient("d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3ee22b996ff6856c27c1f6d88aef0e", "3714fb67de7");
|
||||
expectQuotient("d87becaa3701c97b31b5b8084f2b5b34e7857092", "1",
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
||||
|
||||
expectQuotient("-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e", "-1");
|
||||
expectQuotient("-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092", "0");
|
||||
expectQuotient("-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"a13fac3ee22b996ff6856c27c1f6d88aef0e", "-157b1");
|
||||
expectQuotient("-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3fac3ee22b996ff6856c27c1f6d88aef0e", "-36662bd");
|
||||
expectQuotient("-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"ac3ee22b996ff6856c27c1f6d88aef0e", "-141bfd63e");
|
||||
expectQuotient("-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3ee22b996ff6856c27c1f6d88aef0e", "-3714fb67de7");
|
||||
expectQuotient("-d87becaa3701c97b31b5b8084f2b5b34e7857092", "1",
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
||||
|
||||
expectQuotient("d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e", "-1");
|
||||
expectQuotient("d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092", "0");
|
||||
expectQuotient("d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-a13fac3ee22b996ff6856c27c1f6d88aef0e", "-157b1");
|
||||
expectQuotient("d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-3fac3ee22b996ff6856c27c1f6d88aef0e", "-36662bd");
|
||||
expectQuotient("d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-ac3ee22b996ff6856c27c1f6d88aef0e", "-141bfd63e");
|
||||
expectQuotient("d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-3ee22b996ff6856c27c1f6d88aef0e", "-3714fb67de7");
|
||||
expectQuotient("d87becaa3701c97b31b5b8084f2b5b34e7857092", "-1",
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
||||
|
||||
expectQuotient("-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e", "1");
|
||||
expectQuotient("-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092", "0");
|
||||
expectQuotient("-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-a13fac3ee22b996ff6856c27c1f6d88aef0e", "157b1");
|
||||
expectQuotient("-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-3fac3ee22b996ff6856c27c1f6d88aef0e", "36662bd");
|
||||
expectQuotient("-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-ac3ee22b996ff6856c27c1f6d88aef0e", "141bfd63e");
|
||||
expectQuotient("-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-3ee22b996ff6856c27c1f6d88aef0e", "3714fb67de7");
|
||||
expectQuotient("-d87becaa3701c97b31b5b8084f2b5b34e7857092", "-1",
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
// Copyright (c) 2018, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
// Testing Bigints with and without intrinsics.
|
||||
// VMOptions=--intrinsify --no-enable-asserts
|
||||
// VMOptions=--intrinsify --enable-asserts
|
||||
// VMOptions=--no-intrinsify --enable-asserts
|
||||
// VMOptions=--optimization-counter-threshold=20 --no-background-compilation
|
||||
// VMOptions=--dwarf_stack_traces --no-retain_function_objects --no-retain_code_objects
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
import 'dart:math' show pow;
|
||||
|
||||
main() {
|
||||
// Test integers.
|
||||
testInt(0);
|
||||
for (int i = 0; i < 63; i++) {
|
||||
var n = pow(2, i);
|
||||
testInt(-n - 1);
|
||||
testInt(-n);
|
||||
testInt(-n + 1);
|
||||
testInt(n - 1);
|
||||
testInt(n);
|
||||
testInt(n + 1);
|
||||
}
|
||||
testInt(-0x8000000000000000);
|
||||
|
||||
// Test doubles.
|
||||
testDouble(0.0);
|
||||
testDouble(-0.0, 0.0);
|
||||
for (double d in [
|
||||
1.0,
|
||||
2.0,
|
||||
pow(2.0, 30) - 1,
|
||||
pow(2.0, 30),
|
||||
pow(2.0, 31) - 1,
|
||||
pow(2.0, 31),
|
||||
pow(2.0, 31) + 1,
|
||||
pow(2.0, 32) - 1,
|
||||
pow(2.0, 32),
|
||||
pow(2.0, 32) + 1,
|
||||
pow(2.0, 52) - 1,
|
||||
pow(2.0, 52),
|
||||
pow(2.0, 52) + 1,
|
||||
pow(2.0, 53) - 1,
|
||||
pow(2.0, 53),
|
||||
]) {
|
||||
for (int p = 0; p < 1024; p++) {
|
||||
var value = d * pow(2.0, p); // Valid integer value.
|
||||
if (!value.isFinite) break;
|
||||
testDouble(-value);
|
||||
testDouble(value);
|
||||
}
|
||||
}
|
||||
Expect.equals(BigInt.zero, new BigInt.from(0.5));
|
||||
Expect.equals(BigInt.one, new BigInt.from(1.5));
|
||||
|
||||
Expect.throws(() => new BigInt.from(double.infinity));
|
||||
Expect.throws(() => new BigInt.from(-double.infinity));
|
||||
Expect.throws(() => new BigInt.from(double.nan));
|
||||
}
|
||||
|
||||
testInt(int n) {
|
||||
var bigint = new BigInt.from(n);
|
||||
Expect.equals(n, bigint.toInt());
|
||||
|
||||
// If the integers are inexact (e.g. > 2^53 when represented by doubles as
|
||||
// when compiled to JavaScript numbers) then the 'toString' might be rounded
|
||||
// to the nearest equivalent 'nicer looking' number.
|
||||
if (n == n + 1 || n == n - 1) return;
|
||||
|
||||
Expect.equals("$n", "$bigint");
|
||||
}
|
||||
|
||||
testDouble(double input, [double expectation]) {
|
||||
var bigint = new BigInt.from(input);
|
||||
Expect.equals(expectation ?? input, bigint.toDouble());
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
// Copyright (c) 2018, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
// Testing Bigints with and without intrinsics.
|
||||
// VMOptions=--intrinsify --no-enable-asserts
|
||||
// VMOptions=--intrinsify --enable-asserts
|
||||
// VMOptions=--no-intrinsify --enable-asserts
|
||||
// VMOptions=--optimization-counter-threshold=20 --no-background-compilation
|
||||
|
||||
// Test for JavaScript specific BigInt behaviour. Any JavaScript number (double)
|
||||
// that is an integral value is a Dart 'int' value, so any BigInt that has a
|
||||
// value that is exactly a double integral value should return `true` for
|
||||
// [BigInt.isValidInt].
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
int intPow(int a, int p) {
|
||||
int result = 1;
|
||||
for (int i = 0; i < p; i++) result *= a;
|
||||
return result;
|
||||
}
|
||||
|
||||
int pow2_53 = intPow(2, 53);
|
||||
|
||||
test(int n1, int n2, int shift, [bool expectedIsValidInt = true]) {
|
||||
var n = (new BigInt.from(n1) * new BigInt.from(n2)) << shift;
|
||||
Expect.equals(expectedIsValidInt, n.isValidInt, '${n}.isValidInt');
|
||||
if (n >= new BigInt.from(pow2_53)) {
|
||||
var nplus1 = n + BigInt.one;
|
||||
Expect.isFalse(nplus1.isValidInt, '${nplus1}.isValidInt');
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
test(13, 19, 1);
|
||||
test(19997, 19993, 100);
|
||||
test(19997, pow2_53 ~/ 19997, 0);
|
||||
test(19997, pow2_53 ~/ 19997, 1);
|
||||
test(19997, pow2_53 ~/ 19997, 100);
|
||||
test(1, 1, 100);
|
||||
test(1, 1, 10000, false);
|
||||
|
||||
// More than 53 bits in product,
|
||||
test(pow2_53 ~/ 3, pow2_53 ~/ 5, 0, false);
|
||||
}
|
|
@ -1,114 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
// Testing Bigints with and without intrinsics.
|
||||
// VMOptions=--intrinsify --no-enable-asserts
|
||||
// VMOptions=--intrinsify --enable-asserts
|
||||
// VMOptions=--no-intrinsify --enable-asserts
|
||||
// VMOptions=--no-intrinsify --no-enable-asserts
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
expectRemainder(aString, bString, expectedString) {
|
||||
BigInt a = BigInt.parse(aString, radix: 16);
|
||||
BigInt b = BigInt.parse(bString, radix: 16);
|
||||
BigInt expected = BigInt.parse(expectedString, radix: 16);
|
||||
BigInt actual = a % b;
|
||||
String actualString = actual.toRadixString(16);
|
||||
print("$aString % $bString");
|
||||
print(" = $actualString (expected $expectedString)");
|
||||
Expect.equals(expected, actual);
|
||||
}
|
||||
|
||||
main() {
|
||||
expectRemainder(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"3b04b6a8ac2e74f9845c182e303993e0efa8184");
|
||||
expectRemainder(
|
||||
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e");
|
||||
expectRemainder(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"a13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"1fdbde7efec117ff81df42cc8367092a65e4");
|
||||
expectRemainder(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"359d4ac0e4440150310acc0e96fdb973c");
|
||||
expectRemainder("d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"ac3ee22b996ff6856c27c1f6d88aef0e", "84c9b202365aef6ea4b442ff6897d72e");
|
||||
expectRemainder("d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3ee22b996ff6856c27c1f6d88aef0e", "2c66626e41743605244c026579e4f0");
|
||||
expectRemainder("d87becaa3701c97b31b5b8084f2b5b34e7857092", "1", "0");
|
||||
|
||||
expectRemainder(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d11b55d5217bfadc012a3502892428b8c9906d8a");
|
||||
expectRemainder(
|
||||
"-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3b04b6a8ac2e74f9845c182e303993e0efa8184");
|
||||
expectRemainder(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"a13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"8163cdbfe36a817074a6295b3e8fcf60892a");
|
||||
expectRemainder(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"3c526a361d552fe1825b7b010d68af57d2");
|
||||
expectRemainder("-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"ac3ee22b996ff6856c27c1f6d88aef0e", "2775302963150716c7737ef76ff317e0");
|
||||
expectRemainder("-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3ee22b996ff6856c27c1f6d88aef0e", "127bc92b2e824f670375f473110a1e");
|
||||
expectRemainder("-d87becaa3701c97b31b5b8084f2b5b34e7857092", "1", "0");
|
||||
|
||||
expectRemainder(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"3b04b6a8ac2e74f9845c182e303993e0efa8184");
|
||||
expectRemainder(
|
||||
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e");
|
||||
expectRemainder(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-a13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"1fdbde7efec117ff81df42cc8367092a65e4");
|
||||
expectRemainder(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-3fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"359d4ac0e4440150310acc0e96fdb973c");
|
||||
expectRemainder("d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-ac3ee22b996ff6856c27c1f6d88aef0e", "84c9b202365aef6ea4b442ff6897d72e");
|
||||
expectRemainder("d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-3ee22b996ff6856c27c1f6d88aef0e", "2c66626e41743605244c026579e4f0");
|
||||
expectRemainder("d87becaa3701c97b31b5b8084f2b5b34e7857092", "-1", "0");
|
||||
|
||||
expectRemainder(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d11b55d5217bfadc012a3502892428b8c9906d8a");
|
||||
expectRemainder(
|
||||
"-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3b04b6a8ac2e74f9845c182e303993e0efa8184");
|
||||
expectRemainder(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-a13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"8163cdbfe36a817074a6295b3e8fcf60892a");
|
||||
expectRemainder(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-3fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"3c526a361d552fe1825b7b010d68af57d2");
|
||||
expectRemainder("-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-ac3ee22b996ff6856c27c1f6d88aef0e", "2775302963150716c7737ef76ff317e0");
|
||||
expectRemainder("-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-3ee22b996ff6856c27c1f6d88aef0e", "127bc92b2e824f670375f473110a1e");
|
||||
expectRemainder("-d87becaa3701c97b31b5b8084f2b5b34e7857092", "-1", "0");
|
||||
}
|
|
@ -1,138 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
// Testing Bigints with and without intrinsics.
|
||||
// VMOptions=--intrinsify --no-enable-asserts
|
||||
// VMOptions=--intrinsify --enable-asserts
|
||||
// VMOptions=--no-intrinsify --enable-asserts
|
||||
// VMOptions=--no-intrinsify --no-enable-asserts
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
expectProduct(aString, bString, expectedString) {
|
||||
BigInt a = BigInt.parse(aString, radix: 16);
|
||||
BigInt b = BigInt.parse(bString, radix: 16);
|
||||
BigInt expected = BigInt.parse(expectedString, radix: 16);
|
||||
BigInt actual = a * b;
|
||||
String actualString = actual.toRadixString(16);
|
||||
print("$aString * $bString");
|
||||
print(" = $actualString (expected $expectedString)");
|
||||
Expect.equals(expected, actual);
|
||||
}
|
||||
|
||||
main() {
|
||||
expectProduct(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"b3f2d29d6885d40866b040adf8f545352154823b15fed8aa8c35c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct(
|
||||
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"b3f2d29d6885d40866b040adf8f545352154823b15fed8aa8c35c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"a13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"885bc7febac39cd5592e28ce964bfea66a31ea38d8aa8c35c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"35d827ae2b7d1edeeae0115c81ba4a2496fe6d06aa8c35c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"ac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"91a87047f3ae4999a45912763e9eb292049652bc8c35c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"352d4596b9163adef2fad0a96d914a7908ab1a7435c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct("d87becaa3701c97b31b5b8084f2b5b34e7857092", "1",
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
||||
expectProduct("d87becaa3701c97b31b5b8084f2b5b34e7857092", "0", "0");
|
||||
|
||||
expectProduct(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-b3f2d29d6885d40866b040adf8f545352154823b15fed8aa8c35c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct(
|
||||
"-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-b3f2d29d6885d40866b040adf8f545352154823b15fed8aa8c35c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"a13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-885bc7febac39cd5592e28ce964bfea66a31ea38d8aa8c35c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-35d827ae2b7d1edeeae0115c81ba4a2496fe6d06aa8c35c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"ac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-91a87047f3ae4999a45912763e9eb292049652bc8c35c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-352d4596b9163adef2fad0a96d914a7908ab1a7435c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct("-d87becaa3701c97b31b5b8084f2b5b34e7857092", "1",
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
||||
expectProduct("-d87becaa3701c97b31b5b8084f2b5b34e7857092", "0", "0");
|
||||
|
||||
expectProduct(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-b3f2d29d6885d40866b040adf8f545352154823b15fed8aa8c35c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct(
|
||||
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-b3f2d29d6885d40866b040adf8f545352154823b15fed8aa8c35c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-a13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-885bc7febac39cd5592e28ce964bfea66a31ea38d8aa8c35c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-3fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-35d827ae2b7d1edeeae0115c81ba4a2496fe6d06aa8c35c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-ac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-91a87047f3ae4999a45912763e9eb292049652bc8c35c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-352d4596b9163adef2fad0a96d914a7908ab1a7435c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct("d87becaa3701c97b31b5b8084f2b5b34e7857092", "-1",
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
||||
expectProduct("d87becaa3701c97b31b5b8084f2b5b34e7857092", "-0", "0");
|
||||
|
||||
expectProduct(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"b3f2d29d6885d40866b040adf8f545352154823b15fed8aa8c35c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct(
|
||||
"-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"b3f2d29d6885d40866b040adf8f545352154823b15fed8aa8c35c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-a13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"885bc7febac39cd5592e28ce964bfea66a31ea38d8aa8c35c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-3fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"35d827ae2b7d1edeeae0115c81ba4a2496fe6d06aa8c35c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-ac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"91a87047f3ae4999a45912763e9eb292049652bc8c35c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"352d4596b9163adef2fad0a96d914a7908ab1a7435c5c223fcf4bf6eb904401c1875fc");
|
||||
expectProduct("-d87becaa3701c97b31b5b8084f2b5b34e7857092", "-1",
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
||||
expectProduct("-d87becaa3701c97b31b5b8084f2b5b34e7857092", "-0", "0");
|
||||
}
|
|
@ -1,142 +0,0 @@
|
|||
// Copyright (c) 2017, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
// Testing Bigints with and without intrinsics.
|
||||
// VMOptions=--intrinsify --no-enable-asserts
|
||||
// VMOptions=--intrinsify --enable-asserts
|
||||
// VMOptions=--no-intrinsify --enable-asserts
|
||||
// VMOptions=--optimization-counter-threshold=20 --no-background-compilation
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
import 'dart:math' show pow;
|
||||
|
||||
void testParseRadix() {
|
||||
bool checkedMode = false;
|
||||
assert((checkedMode = true));
|
||||
const String oneByteWhiteSpace = "\x09\x0a\x0b\x0c\x0d\x20"
|
||||
// "\x85" // Might make troubles on some systems. Was marked as OK test.
|
||||
"\xa0";
|
||||
const String whiteSpace = "$oneByteWhiteSpace\u1680"
|
||||
"\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a"
|
||||
"\u2028\u2029\u202f\u205f\u3000\ufeff";
|
||||
|
||||
var digits = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
var zeros = "0" * 64;
|
||||
|
||||
for (int i = 0; i < whiteSpace.length; i++) {
|
||||
var ws = whiteSpace[i];
|
||||
Expect.equals(BigInt.zero, BigInt.parse("${ws}0${ws}", radix: 2));
|
||||
}
|
||||
|
||||
void testParse(BigInt result, String radixString, int radix) {
|
||||
var m = "$radixString/$radix->$result";
|
||||
Expect.equals(
|
||||
result, BigInt.parse(radixString.toLowerCase(), radix: radix), m);
|
||||
Expect.equals(
|
||||
result, BigInt.parse(radixString.toUpperCase(), radix: radix), m);
|
||||
Expect.equals(result, BigInt.parse(" $radixString", radix: radix), m);
|
||||
Expect.equals(result, BigInt.parse("$radixString ", radix: radix), m);
|
||||
Expect.equals(result, BigInt.parse(" $radixString ", radix: radix), m);
|
||||
Expect.equals(result, BigInt.parse("+$radixString", radix: radix), m);
|
||||
Expect.equals(result, BigInt.parse(" +$radixString", radix: radix), m);
|
||||
Expect.equals(result, BigInt.parse("+$radixString ", radix: radix), m);
|
||||
Expect.equals(result, BigInt.parse(" +$radixString ", radix: radix), m);
|
||||
Expect.equals(-result, BigInt.parse("-$radixString", radix: radix), m);
|
||||
Expect.equals(-result, BigInt.parse(" -$radixString", radix: radix), m);
|
||||
Expect.equals(-result, BigInt.parse("-$radixString ", radix: radix), m);
|
||||
Expect.equals(-result, BigInt.parse(" -$radixString ", radix: radix), m);
|
||||
Expect.equals(
|
||||
result,
|
||||
BigInt.parse("$oneByteWhiteSpace$radixString$oneByteWhiteSpace",
|
||||
radix: radix),
|
||||
m);
|
||||
Expect.equals(
|
||||
-result,
|
||||
BigInt.parse("$oneByteWhiteSpace-$radixString$oneByteWhiteSpace",
|
||||
radix: radix),
|
||||
m);
|
||||
Expect.equals(result,
|
||||
BigInt.parse("$whiteSpace$radixString$whiteSpace", radix: radix), m);
|
||||
Expect.equals(-result,
|
||||
BigInt.parse("$whiteSpace-$radixString$whiteSpace", radix: radix), m);
|
||||
|
||||
Expect.equals(result, BigInt.parse("$zeros$radixString", radix: radix), m);
|
||||
Expect.equals(result, BigInt.parse("+$zeros$radixString", radix: radix), m);
|
||||
Expect.equals(
|
||||
-result, BigInt.parse("-$zeros$radixString", radix: radix), m);
|
||||
}
|
||||
|
||||
for (int r = 2; r <= 36; r++) {
|
||||
for (var i = BigInt.zero; i <= new BigInt.from(r * r); i += BigInt.one) {
|
||||
String radixString = i.toRadixString(r);
|
||||
testParse(i, radixString, r);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 2; i <= 36; i++) {
|
||||
var digit = digits[i - 1];
|
||||
testParse(new BigInt.from(i).pow(64) - BigInt.one, digit * 64, i);
|
||||
testParse(BigInt.zero, zeros, i);
|
||||
}
|
||||
|
||||
// Allow both upper- and lower-case letters.
|
||||
Expect.equals(new BigInt.from(0xABCD), BigInt.parse("ABCD", radix: 16));
|
||||
Expect.equals(new BigInt.from(0xABCD), BigInt.parse("abcd", radix: 16));
|
||||
Expect.equals(new BigInt.from(15628859), BigInt.parse("09azAZ", radix: 36));
|
||||
|
||||
Expect.equals(
|
||||
(new BigInt.from(0x12345678) << 96) +
|
||||
(new BigInt.from(0x12345678) << 64) +
|
||||
(new BigInt.from(0x12345678) << 32) +
|
||||
new BigInt.from(0x12345678),
|
||||
BigInt.parse("0x12345678123456781234567812345678"));
|
||||
|
||||
// Allow whitespace before and after the number.
|
||||
Expect.equals(BigInt.one, BigInt.parse(" 1", radix: 2));
|
||||
Expect.equals(BigInt.one, BigInt.parse("1 ", radix: 2));
|
||||
Expect.equals(BigInt.one, BigInt.parse(" 1 ", radix: 2));
|
||||
Expect.equals(BigInt.one, BigInt.parse("\n1", radix: 2));
|
||||
Expect.equals(BigInt.one, BigInt.parse("1\n", radix: 2));
|
||||
Expect.equals(BigInt.one, BigInt.parse("\n1\n", radix: 2));
|
||||
Expect.equals(BigInt.one, BigInt.parse("+1", radix: 2));
|
||||
|
||||
void testFails(String source, int radix) {
|
||||
Expect.throws(() {
|
||||
BigInt.parse(source, radix: radix);
|
||||
}, (e) => e is FormatException, "$source/$radix");
|
||||
}
|
||||
|
||||
for (int i = 2; i < 36; i++) {
|
||||
var char = i.toRadixString(36);
|
||||
testFails(char.toLowerCase(), i);
|
||||
testFails(char.toUpperCase(), i);
|
||||
}
|
||||
testFails("", 2);
|
||||
testFails("+ 1", 2); // No space between sign and digits.
|
||||
testFails("- 1", 2); // No space between sign and digits.
|
||||
testFails("0x", null);
|
||||
for (int i = 2; i <= 33; i++) {
|
||||
// No 0x specially allowed.
|
||||
// At radix 34 and above, "x" is a valid digit.
|
||||
testFails("0x10", i);
|
||||
}
|
||||
|
||||
testBadArguments(String source, int radix) {
|
||||
// If the types match, it should be an ArgumentError of some sort.
|
||||
Expect.throws(
|
||||
() => BigInt.parse(source, radix: radix), (e) => e is ArgumentError);
|
||||
}
|
||||
|
||||
testBadArguments("0", -1);
|
||||
testBadArguments("0", 0);
|
||||
testBadArguments("0", 1);
|
||||
testBadArguments("0", 37);
|
||||
}
|
||||
|
||||
main() {
|
||||
testParseRadix();
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
// Testing Bigints with and without intrinsics.
|
||||
// VMOptions=--intrinsify --no-enable-asserts
|
||||
// VMOptions=--intrinsify --enable-asserts
|
||||
// VMOptions=--no-intrinsify --enable-asserts
|
||||
// VMOptions=--no-intrinsify --no-enable-asserts
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
expectShifted(aString, n, expectedString) {
|
||||
BigInt a = BigInt.parse(aString, radix: 16);
|
||||
BigInt expected = BigInt.parse(expectedString, radix: 16);
|
||||
BigInt actual = a << n;
|
||||
String actualString = actual.toRadixString(16);
|
||||
print("$aString << $n");
|
||||
print(" = $actualString (expected $expectedString)");
|
||||
Expect.equals(expected, actual);
|
||||
}
|
||||
|
||||
main() {
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 0,
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 1,
|
||||
"1b0f7d9546e0392f6636b70109e56b669cf0ae124");
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 2,
|
||||
"361efb2a8dc0725ecc6d6e0213cad6cd39e15c248");
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 31,
|
||||
"6c3df6551b80e4bd98dadc042795ad9a73c2b84900000000");
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 32,
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e785709200000000");
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 33,
|
||||
"1b0f7d9546e0392f6636b70109e56b669cf0ae12400000000");
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 63,
|
||||
"6c3df6551b80e4bd98dadc042795ad9a73c2b8490000000000000000");
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 64,
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e78570920000000000000000");
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 65,
|
||||
"1b0f7d9546e0392f6636b70109e56b669cf0ae1240000000000000000");
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 127,
|
||||
"6c3df6551b80e4bd98dadc042795ad9a73c2b84900000000000000000000000000000000");
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 128,
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e785709200000000000000000000000000000000");
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 129,
|
||||
"1b0f7d9546e0392f6636b70109e56b669cf0ae12400000000000000000000000000000000");
|
||||
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 0,
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 1,
|
||||
"-1b0f7d9546e0392f6636b70109e56b669cf0ae124");
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 2,
|
||||
"-361efb2a8dc0725ecc6d6e0213cad6cd39e15c248");
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 31,
|
||||
"-6c3df6551b80e4bd98dadc042795ad9a73c2b84900000000");
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 32,
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e785709200000000");
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 33,
|
||||
"-1b0f7d9546e0392f6636b70109e56b669cf0ae12400000000");
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 63,
|
||||
"-6c3df6551b80e4bd98dadc042795ad9a73c2b8490000000000000000");
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 64,
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e78570920000000000000000");
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 65,
|
||||
"-1b0f7d9546e0392f6636b70109e56b669cf0ae1240000000000000000");
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 127,
|
||||
"-6c3df6551b80e4bd98dadc042795ad9a73c2b84900000000000000000000000000000000");
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 128,
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e785709200000000000000000000000000000000");
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 129,
|
||||
"-1b0f7d9546e0392f6636b70109e56b669cf0ae12400000000000000000000000000000000");
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
// Testing Bigints with and without intrinsics.
|
||||
// VMOptions=--intrinsify --no-enable-asserts
|
||||
// VMOptions=--intrinsify --enable-asserts
|
||||
// VMOptions=--no-intrinsify --enable-asserts
|
||||
// VMOptions=--no-intrinsify --no-enable-asserts
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
expectShifted(aString, n, expectedString) {
|
||||
BigInt a = BigInt.parse(aString, radix: 16);
|
||||
BigInt expected = BigInt.parse(expectedString, radix: 16);
|
||||
BigInt actual = a >> n;
|
||||
String actualString = actual.toRadixString(16);
|
||||
print("$aString >> $n");
|
||||
print(" = $actualString (expected $expectedString)");
|
||||
Expect.equals(expected, actual);
|
||||
}
|
||||
|
||||
main() {
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 0,
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 1,
|
||||
"6c3df6551b80e4bd98dadc042795ad9a73c2b849");
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 2,
|
||||
"361efb2a8dc0725ecc6d6e0213cad6cd39e15c24");
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 31,
|
||||
"1b0f7d9546e0392f6636b70109e56b669");
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 32,
|
||||
"d87becaa3701c97b31b5b8084f2b5b34");
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 33,
|
||||
"6c3df6551b80e4bd98dadc042795ad9a");
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 63,
|
||||
"1b0f7d9546e0392f6636b7010");
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 64,
|
||||
"d87becaa3701c97b31b5b808");
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 65,
|
||||
"6c3df6551b80e4bd98dadc04");
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 127, "1b0f7d954");
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 128, "d87becaa");
|
||||
expectShifted("d87becaa3701c97b31b5b8084f2b5b34e7857092", 129, "6c3df655");
|
||||
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 0,
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 1,
|
||||
"-6c3df6551b80e4bd98dadc042795ad9a73c2b849");
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 2,
|
||||
"-361efb2a8dc0725ecc6d6e0213cad6cd39e15c25");
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 31,
|
||||
"-1b0f7d9546e0392f6636b70109e56b66a");
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 32,
|
||||
"-d87becaa3701c97b31b5b8084f2b5b35");
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 33,
|
||||
"-6c3df6551b80e4bd98dadc042795ad9b");
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 63,
|
||||
"-1b0f7d9546e0392f6636b7011");
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 64,
|
||||
"-d87becaa3701c97b31b5b809");
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 65,
|
||||
"-6c3df6551b80e4bd98dadc05");
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 127, "-1b0f7d955");
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 128, "-d87becab");
|
||||
expectShifted("-d87becaa3701c97b31b5b8084f2b5b34e7857092", 129, "-6c3df656");
|
||||
}
|
|
@ -1,142 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
// Testing Bigints with and without intrinsics.
|
||||
// VMOptions=--intrinsify --no-enable-asserts
|
||||
// VMOptions=--intrinsify --enable-asserts
|
||||
// VMOptions=--no-intrinsify --enable-asserts
|
||||
// VMOptions=--no-intrinsify --no-enable-asserts
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
expectDifference(aString, bString, expectedString) {
|
||||
BigInt a = BigInt.parse(aString, radix: 16);
|
||||
BigInt b = BigInt.parse(bString, radix: 16);
|
||||
BigInt expected = BigInt.parse(expectedString, radix: 16);
|
||||
BigInt actual = a - b;
|
||||
String actualString = actual.toRadixString(16);
|
||||
print("$aString - $bString");
|
||||
print(" = $actualString (expected $expectedString)");
|
||||
Expect.equals(expected, actual);
|
||||
}
|
||||
|
||||
main() {
|
||||
expectDifference(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"3b04b6a8ac2e74f9845c182e303993e0efa8184");
|
||||
expectDifference(
|
||||
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-3b04b6a8ac2e74f9845c182e303993e0efa8184");
|
||||
expectDifference(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"a13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87b4b6a8ac2e74f9845c182e303993e0efa8184");
|
||||
expectDifference(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87bec6a8ac2e74f9845c182e303993e0efa8184");
|
||||
expectDifference(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"ac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87beca98ac2e74f9845c182e303993e0efa8184");
|
||||
expectDifference(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87becaa36c2e74f9845c182e303993e0efa8184");
|
||||
expectDifference("d87becaa3701c97b31b5b8084f2b5b34e7857092", "1",
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857091");
|
||||
expectDifference("d87becaa3701c97b31b5b8084f2b5b34e7857092", "0",
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
||||
|
||||
expectDifference(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-1ad478de9e340aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectDifference(
|
||||
"-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-1ad478de9e340aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectDifference(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"a13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87c8de9e340aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectDifference(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87bece9e340aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectDifference(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"ac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87becaae340aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectDifference(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87becaa3740aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectDifference("-d87becaa3701c97b31b5b8084f2b5b34e7857092", "1",
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857093");
|
||||
expectDifference("-d87becaa3701c97b31b5b8084f2b5b34e7857092", "0",
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
||||
|
||||
expectDifference(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"1ad478de9e340aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectDifference(
|
||||
"d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"1ad478de9e340aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectDifference(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-a13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87c8de9e340aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectDifference(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-3fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87bece9e340aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectDifference(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-ac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87becaae340aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectDifference(
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"d87becaa3740aba6cb25ae8dbb531d2bc0105fa0");
|
||||
expectDifference("d87becaa3701c97b31b5b8084f2b5b34e7857092", "-1",
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857093");
|
||||
expectDifference("d87becaa3701c97b31b5b8084f2b5b34e7857092", "-0",
|
||||
"d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
||||
|
||||
expectDifference(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-3b04b6a8ac2e74f9845c182e303993e0efa8184");
|
||||
expectDifference(
|
||||
"-d4cba13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"3b04b6a8ac2e74f9845c182e303993e0efa8184");
|
||||
expectDifference(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-a13fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87b4b6a8ac2e74f9845c182e303993e0efa8184");
|
||||
expectDifference(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-3fac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87bec6a8ac2e74f9845c182e303993e0efa8184");
|
||||
expectDifference(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-ac3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87beca98ac2e74f9845c182e303993e0efa8184");
|
||||
expectDifference(
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092",
|
||||
"-3ee22b996ff6856c27c1f6d88aef0e",
|
||||
"-d87becaa36c2e74f9845c182e303993e0efa8184");
|
||||
expectDifference("-d87becaa3701c97b31b5b8084f2b5b34e7857092", "-1",
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857091");
|
||||
expectDifference("-d87becaa3701c97b31b5b8084f2b5b34e7857092", "-0",
|
||||
"-d87becaa3701c97b31b5b8084f2b5b34e7857092");
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,186 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
// Testing int.bitLength, int.toUnsigned and int.toSigned.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
library bit_twiddling_test;
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
testBitLength() {
|
||||
check(int i, width) {
|
||||
Expect.equals(width, i.bitLength, '$i.bitLength == $width');
|
||||
// (~i) written as (-i-1) to avoid issues with limited range of dart2js ops.
|
||||
Expect.equals(width, (-i - 1).bitLength, '(~$i).bitLength == $width');
|
||||
}
|
||||
|
||||
check(0, 0);
|
||||
check(1, 1);
|
||||
check(2, 2);
|
||||
check(3, 2);
|
||||
check(4, 3);
|
||||
check(5, 3);
|
||||
check(6, 3);
|
||||
check(7, 3);
|
||||
check(8, 4);
|
||||
check(127, 7);
|
||||
check(128, 8);
|
||||
check(129, 8);
|
||||
check(2147483646, 31);
|
||||
check(2147483647, 31);
|
||||
check(2147483648, 32);
|
||||
check(2147483649, 32);
|
||||
check(4294967295, 32);
|
||||
check(4294967296, 33);
|
||||
check(0xffffffffff, 40);
|
||||
check(0xfffffffffff, 44);
|
||||
check(0xffffffffffff, 48);
|
||||
check(0x1000000000000, 49);
|
||||
check(0x1000000000001, 49);
|
||||
check(0x1ffffffffffff, 49);
|
||||
check(0x2000000000000, 50);
|
||||
check(0x2000000000001, 50);
|
||||
|
||||
check(0xffffffffffffff, 56); // //# int64: ok
|
||||
check(0x7fffffffffffffff, 63); // //# int64: continued
|
||||
check(0xffffffffffffffff, 0); // //# int64: continued
|
||||
}
|
||||
|
||||
testToUnsigned() {
|
||||
checkU(src, width, expected) {
|
||||
Expect.equals(expected, src.toUnsigned(width));
|
||||
}
|
||||
|
||||
checkU(1, 8, 1);
|
||||
checkU(0xff, 8, 0xff);
|
||||
checkU(0xffff, 8, 0xff);
|
||||
checkU(-1, 8, 0xff);
|
||||
checkU(0xffffffff, 32, 0xffffffff);
|
||||
|
||||
checkU(0x7fffffff, 30, 0x3fffffff);
|
||||
checkU(0x7fffffff, 31, 0x7fffffff);
|
||||
checkU(0x7fffffff, 32, 0x7fffffff);
|
||||
checkU(0x80000000, 30, 0);
|
||||
checkU(0x80000000, 31, 0);
|
||||
checkU(0x80000000, 32, 0x80000000);
|
||||
checkU(0xffffffff, 30, 0x3fffffff);
|
||||
checkU(0xffffffff, 31, 0x7fffffff);
|
||||
checkU(0xffffffff, 32, 0xffffffff);
|
||||
checkU(0x100000000, 30, 0);
|
||||
checkU(0x100000000, 31, 0);
|
||||
checkU(0x100000000, 32, 0);
|
||||
checkU(0x1ffffffff, 30, 0x3fffffff);
|
||||
checkU(0x1ffffffff, 31, 0x7fffffff);
|
||||
checkU(0x1ffffffff, 32, 0xffffffff);
|
||||
|
||||
checkU(-1, 0, 0);
|
||||
checkU(0, 0, 0);
|
||||
checkU(1, 0, 0);
|
||||
checkU(2, 0, 0);
|
||||
checkU(3, 0, 0);
|
||||
|
||||
checkU(-1, 1, 1);
|
||||
checkU(0, 1, 0);
|
||||
checkU(1, 1, 1);
|
||||
checkU(2, 1, 0);
|
||||
checkU(3, 1, 1);
|
||||
checkU(4, 1, 0);
|
||||
|
||||
checkU(-1, 2, 3);
|
||||
checkU(0, 2, 0);
|
||||
checkU(1, 2, 1);
|
||||
checkU(2, 2, 2);
|
||||
checkU(3, 2, 3);
|
||||
checkU(4, 2, 0);
|
||||
|
||||
checkU(-1, 3, 7);
|
||||
checkU(0, 3, 0);
|
||||
checkU(1, 3, 1);
|
||||
checkU(2, 3, 2);
|
||||
checkU(3, 3, 3);
|
||||
checkU(4, 3, 4);
|
||||
|
||||
checkU(0x0100000000000001, 2, 1); // //# int64: continued
|
||||
checkU(0x0200000000000001, 60, 0x200000000000001); // //# int64: continued
|
||||
checkU(0x0200000000000001, 59, 0x200000000000001); // //# int64: continued
|
||||
checkU(0x0200000000000001, 58, 0x200000000000001); // //# int64: continued
|
||||
checkU(0x0200000000000001, 57, 1); // //# int64: continued
|
||||
|
||||
checkU(0x8100000000000001, 2, 1); // //# int64: continued
|
||||
checkU(0x8200000000000001, 60, 0x200000000000001); // //# int64: continued
|
||||
checkU(0x8200000000000001, 59, 0x200000000000001); // //# int64: continued
|
||||
checkU(0x8200000000000001, 58, 0x200000000000001); // //# int64: continued
|
||||
checkU(0x8200000000000001, 57, 1); // //# int64: continued
|
||||
}
|
||||
|
||||
testToSigned() {
|
||||
checkS(src, width, expected) {
|
||||
Expect.equals(
|
||||
expected, src.toSigned(width), '$src.toSigned($width) == $expected');
|
||||
}
|
||||
|
||||
checkS(1, 8, 1);
|
||||
checkS(0xff, 8, -1);
|
||||
checkS(0xffff, 8, -1);
|
||||
checkS(-1, 8, -1);
|
||||
checkS(128, 8, -128);
|
||||
checkS(0xffffffff, 32, -1);
|
||||
|
||||
checkS(0x7fffffff, 30, -1);
|
||||
checkS(0x7fffffff, 31, -1);
|
||||
checkS(0x7fffffff, 32, 0x7fffffff);
|
||||
checkS(0x80000000, 30, 0);
|
||||
checkS(0x80000000, 31, 0);
|
||||
checkS(0x80000000, 32, -2147483648);
|
||||
checkS(0xffffffff, 30, -1);
|
||||
checkS(0xffffffff, 31, -1);
|
||||
checkS(0xffffffff, 32, -1);
|
||||
|
||||
checkS(0x100000000, 30, 0);
|
||||
checkS(0x100000000, 31, 0);
|
||||
checkS(0x100000000, 32, 0);
|
||||
checkS(0x1ffffffff, 30, -1);
|
||||
checkS(0x1ffffffff, 31, -1);
|
||||
checkS(0x1ffffffff, 32, -1);
|
||||
|
||||
checkS(-1, 1, -1);
|
||||
checkS(0, 1, 0);
|
||||
checkS(1, 1, -1); // The only bit is the sign bit.
|
||||
checkS(2, 1, 0);
|
||||
checkS(3, 1, -1);
|
||||
checkS(4, 1, 0);
|
||||
|
||||
checkS(-1, 2, -1);
|
||||
checkS(0, 2, 0);
|
||||
checkS(1, 2, 1);
|
||||
checkS(2, 2, -2);
|
||||
checkS(3, 2, -1);
|
||||
checkS(4, 2, 0);
|
||||
|
||||
checkS(-1, 3, -1);
|
||||
checkS(0, 3, 0);
|
||||
checkS(1, 3, 1);
|
||||
checkS(2, 3, 2);
|
||||
checkS(3, 3, 3);
|
||||
checkS(4, 3, -4);
|
||||
|
||||
checkS(0x0100000000000001, 2, 1); // //# int64: continued
|
||||
checkS(0x0200000000000001, 60, 0x200000000000001); // //# int64: continued
|
||||
checkS(0x0200000000000001, 59, 0x200000000000001); // //# int64: continued
|
||||
checkS(0x0200000000000001, 58, -0x200000000000000 + 1); // //# int64: continued
|
||||
checkS(0x0200000000000001, 57, 1); // //# int64: continued
|
||||
|
||||
checkS(0x8100000000000001, 2, 1); // //# int64: continued
|
||||
checkS(0x8200000000000001, 60, 0x200000000000001); // //# int64: continued
|
||||
checkS(0x8200000000000001, 59, 0x200000000000001); // //# int64: continued
|
||||
checkS(0x8200000000000001, 58, -0x200000000000000 + 1); // //# int64: continued
|
||||
checkS(0x8200000000000001, 57, 1); // //# int64: continued
|
||||
}
|
||||
|
||||
main() {
|
||||
testBitLength();
|
||||
testToUnsigned();
|
||||
testToSigned();
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
main() {
|
||||
const bool.fromEnvironment('NOT_FOUND', defaultValue: ''); // //# 01: compile-time error
|
||||
const bool.fromEnvironment('NOT_FOUND', defaultValue: 1); // //# 02: compile-time error
|
||||
const bool.fromEnvironment(null); // //# 03: compile-time error
|
||||
const bool.fromEnvironment(1); // //# 04: compile-time error
|
||||
const bool.fromEnvironment([]); // //# 05: compile-time error
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
// SharedOptions=-Da=true -Db=false -Dc=NOTBOOL -Dd=True
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
main() {
|
||||
Expect.isTrue(const bool.fromEnvironment('a'));
|
||||
Expect.isFalse(const bool.fromEnvironment('b'));
|
||||
Expect.isTrue(const bool.fromEnvironment('c', defaultValue: true));
|
||||
Expect.isFalse(const bool.fromEnvironment('c', defaultValue: false));
|
||||
Expect.isFalse(const bool.fromEnvironment('d', defaultValue: false));
|
||||
Expect.equals(const bool.fromEnvironment('dart.isVM'), !identical(1.0, 1));
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
// Copyright (c) 2012, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
class BoolHashCodeTest {
|
||||
static testMain() {
|
||||
Expect.notEquals(true.hashCode, false.hashCode);
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
BoolHashCodeTest.testMain();
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
// Copyright (c) 2017, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
main() {
|
||||
void test(bool b1, bool b2) {
|
||||
var and1 = b1 && b2;
|
||||
var and2 = b1 & b2;
|
||||
var and3 = b1 ? b2 ? true : false : false;
|
||||
var or1 = b1 || b2;
|
||||
var or2 = b1 | b2;
|
||||
var or3 = b1 ? true : b2 ? true : false;
|
||||
var xor1 = b1 != b2;
|
||||
var xor2 = b1 ^ b2;
|
||||
var xor3 = b1 ? b2 ? false : true : b2 ? true : false;
|
||||
var nb1 = !b1;
|
||||
var nb2 = !b2;
|
||||
Expect.equals(and3, and1);
|
||||
Expect.equals(and3, and2);
|
||||
Expect.equals(or3, or1);
|
||||
Expect.equals(or3, or2);
|
||||
Expect.equals(xor3, xor1);
|
||||
Expect.equals(xor3, xor2);
|
||||
Expect.notEquals(nb1, b1);
|
||||
Expect.notEquals(nb2, b2);
|
||||
}
|
||||
|
||||
test(true, false);
|
||||
test(true, true);
|
||||
test(false, true);
|
||||
test(false, false);
|
||||
|
||||
Expect.isTrue(true || (throw "unreachable"));
|
||||
Expect.throws(() => false || (throw "unreachable"));
|
||||
|
||||
Expect.isFalse(false && (throw "unreachable"));
|
||||
Expect.throws(() => true && (throw "unreachable"));
|
||||
|
||||
Expect.throws(() => true | (throw "unreachable"));
|
||||
Expect.throws(() => false | (throw "unreachable"));
|
||||
|
||||
Expect.throws(() => true & (throw "unreachable"));
|
||||
Expect.throws(() => false & (throw "unreachable"));
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
final elements = <C>[c, d, e, f, null];
|
||||
|
||||
class C {}
|
||||
|
||||
class D extends C {}
|
||||
|
||||
class E extends C {}
|
||||
|
||||
class F implements D, E {}
|
||||
|
||||
final c = C();
|
||||
final d = D();
|
||||
final e = E();
|
||||
final f = F();
|
|
@ -1,70 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "dart:collection";
|
||||
import "package:expect/expect.dart";
|
||||
import 'cast_helper.dart';
|
||||
|
||||
void main() {
|
||||
testDowncastDirectAccess();
|
||||
testDowncastNoDirectAccess();
|
||||
testDowncastUntouchableElements();
|
||||
testUpcast();
|
||||
}
|
||||
|
||||
void testDowncastDirectAccess() {
|
||||
var iterable = new Iterable<C>.generate(elements.length, (n) => elements[n]);
|
||||
|
||||
// An iterable that (likely) can do direct access.
|
||||
var dIterable = Iterable.castFrom<C, D>(iterable);
|
||||
|
||||
Expect.throws(() => dIterable.first, null, "direct.first");
|
||||
Expect.equals(d, dIterable.elementAt(1));
|
||||
Expect.throws(() => dIterable.elementAt(2), null, "direct.2"); // E is not D.
|
||||
Expect.equals(f, dIterable.skip(3).first); // Skip does not access element.
|
||||
Expect.equals(null, dIterable.skip(3).elementAt(1));
|
||||
|
||||
Expect.throws(() => dIterable.toList(), null, "direct.toList");
|
||||
}
|
||||
|
||||
void testDowncastNoDirectAccess() {
|
||||
var iterable = new Iterable<C>.generate(elements.length, (n) => elements[n]);
|
||||
|
||||
// An iterable that cannot do direct access.
|
||||
var dIterable = Iterable.castFrom<C, D>(iterable.where((_) => true));
|
||||
|
||||
Expect.throws(() => dIterable.first, null, "nonDirect.first");
|
||||
Expect.equals(d, dIterable.elementAt(1));
|
||||
// E is not D.
|
||||
Expect.throws(() => dIterable.elementAt(2), null, "nonDirect.2");
|
||||
Expect.equals(f, dIterable.skip(3).first); // Skip does not access element.
|
||||
Expect.equals(null, dIterable.skip(3).elementAt(1));
|
||||
|
||||
Expect.throws(() => dIterable.toList(), null, "nonDirect.toList");
|
||||
}
|
||||
|
||||
void testDowncastUntouchableElements() {
|
||||
// Iterable that definitely won't survive accessing element 3.
|
||||
var iterable = new Iterable<C>.generate(
|
||||
elements.length, (n) => n == 3 ? throw "untouchable" : elements[n]);
|
||||
var dIterable = Iterable.castFrom<C, D>(iterable);
|
||||
|
||||
Expect.throws(() => dIterable.first, null, "untouchable.first");
|
||||
Expect.equals(d, dIterable.elementAt(1));
|
||||
Expect.throws(() => dIterable.elementAt(3), null, "untouchable.3");
|
||||
// Skip does not access element.
|
||||
Expect.equals(null, dIterable.skip(4).first);
|
||||
Expect.equals(null, dIterable.skip(3).elementAt(1));
|
||||
|
||||
Expect.throws(() => dIterable.toList(), null, "untouchable.toList");
|
||||
}
|
||||
|
||||
void testUpcast() {
|
||||
var iterable = new Iterable<C>.generate(elements.length, (n) => elements[n]);
|
||||
|
||||
var objectIterable = Iterable.castFrom<C, Object>(iterable);
|
||||
Expect.listEquals(elements, objectIterable.toList());
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "dart:collection";
|
||||
import "package:expect/expect.dart";
|
||||
import 'cast_helper.dart';
|
||||
|
||||
void main() {
|
||||
testDowncast();
|
||||
testUpcast();
|
||||
testRegression();
|
||||
}
|
||||
|
||||
void testDowncast() {
|
||||
var list = new List<C>.from(elements);
|
||||
var dList = List.castFrom<C, D>(list);
|
||||
|
||||
Expect.throws(() => dList.first); // C is not D.
|
||||
Expect.equals(d, dList[1]);
|
||||
Expect.throws(() => dList[2]); // E is not D.
|
||||
Expect.equals(f, dList[3]);
|
||||
Expect.equals(null, dList.last);
|
||||
|
||||
Expect.throws(() => dList.toList());
|
||||
|
||||
// Setting works.
|
||||
dList[2] = d;
|
||||
Expect.equals(d, dList[2]);
|
||||
}
|
||||
|
||||
void testUpcast() {
|
||||
var list2 = new List<C>.from(elements);
|
||||
var dList2 = List.castFrom<C, Object>(list2);
|
||||
Expect.listEquals(elements, dList2);
|
||||
Expect.throws(() => dList2[2] = new Object()); // Cannot set non-C.
|
||||
Expect.listEquals(elements, dList2);
|
||||
}
|
||||
|
||||
void testRegression() {
|
||||
var numList = <num>[4, 3, 2, 1];
|
||||
var intList = numList.cast<int>();
|
||||
intList.sort(null);
|
||||
Expect.listEquals([1, 2, 3, 4], numList);
|
||||
Expect.listEquals([1, 2, 3, 4], intList);
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "dart:collection";
|
||||
import "package:expect/expect.dart";
|
||||
import 'cast_helper.dart';
|
||||
|
||||
void main() {
|
||||
testDowncast();
|
||||
testUpcast();
|
||||
}
|
||||
|
||||
void testDowncast() {
|
||||
var map = new Map.fromIterables(elements, elements);
|
||||
var dMap = Map.castFrom<C, C, D, D>(map);
|
||||
|
||||
Expect.isTrue(dMap is Map<D, D>);
|
||||
|
||||
Expect.equals(null, dMap[new C()]);
|
||||
Expect.throws(() => dMap[c]); // C is not D.
|
||||
Expect.isTrue(dMap.containsKey(c)); // containsKey should not be typed.
|
||||
Expect.equals(d, dMap[d]);
|
||||
Expect.throws(() => dMap[e]); // E is not D.
|
||||
Expect.isTrue(dMap.containsKey(null));
|
||||
Expect.equals(null, dMap[null]);
|
||||
|
||||
Expect.equals(5, dMap.length);
|
||||
Expect.throws(() => dMap.remove(c)); // Removes key but fails to return value.
|
||||
Expect.equals(4, dMap.length);
|
||||
Expect.equals(null, dMap[c]);
|
||||
|
||||
// Runtime errors when assigning or accessing a C.
|
||||
Expect.throws(() => dMap[c] = d);
|
||||
Expect.throws(() => dMap[d] = c);
|
||||
Expect.equals(4, dMap.length);
|
||||
|
||||
// Test keys and values.
|
||||
Expect.isTrue(dMap.keys is Iterable<D>);
|
||||
Expect.isTrue(dMap.values is Iterable<D>);
|
||||
Expect.throws(() => dMap.keys.toList());
|
||||
Expect.throws(() => dMap.values.toList());
|
||||
}
|
||||
|
||||
void testUpcast() {
|
||||
var map = new Map.fromIterables(elements, elements);
|
||||
var objectMap = Map.castFrom<C, C, Object, Object>(map);
|
||||
|
||||
Expect.equals(5, objectMap.length);
|
||||
Expect.equals(c, objectMap[c]);
|
||||
Expect.isTrue(objectMap.containsKey(c));
|
||||
Expect.equals(c, objectMap.remove(c));
|
||||
Expect.equals(4, objectMap.length);
|
||||
|
||||
// Test keys and values.
|
||||
Expect.isTrue(objectMap.keys is Iterable<Object>);
|
||||
Expect.isTrue(objectMap.values is Iterable<Object>);
|
||||
var expected = new List<Object>.from(elements);
|
||||
expected.remove(c);
|
||||
Expect.listEquals(expected, objectMap.keys.toList());
|
||||
Expect.listEquals(expected, objectMap.values.toList());
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "dart:collection";
|
||||
import "package:expect/expect.dart";
|
||||
import 'cast_helper.dart';
|
||||
|
||||
void main() {
|
||||
testOrder();
|
||||
testDowncast();
|
||||
testUpcast();
|
||||
testNewSet();
|
||||
}
|
||||
|
||||
void testOrder() {
|
||||
var setEls = new Set<C>.from(elements); // Linked HashSet.
|
||||
Expect.listEquals(elements, setEls.toList()); // Preserves order.
|
||||
}
|
||||
|
||||
void testDowncast() {
|
||||
var setEls = new Set<C>.from(elements);
|
||||
var dSet = Set.castFrom<C, D>(setEls);
|
||||
|
||||
// Preserves order.
|
||||
Expect.throws(() => dSet.first); // C is not D.
|
||||
Expect.equals(d, dSet.elementAt(1));
|
||||
Expect.throws(() => dSet.elementAt(2)); // E is not D.
|
||||
Expect.equals(f, dSet.elementAt(3));
|
||||
Expect.equals(null, dSet.elementAt(4));
|
||||
|
||||
Expect.throws(() => dSet.toList());
|
||||
|
||||
// Contains should not be typed.
|
||||
var newC = new C();
|
||||
Expect.isFalse(dSet.contains(newC));
|
||||
Expect.throws(() => dSet.add(newC));
|
||||
Expect.isFalse(dSet.contains(newC));
|
||||
Expect.isTrue(dSet.contains(c));
|
||||
|
||||
// Remove and length should not be typed.
|
||||
Expect.equals(5, dSet.length);
|
||||
dSet.remove(c); // Success, no type checks.
|
||||
Expect.equals(4, dSet.length);
|
||||
}
|
||||
|
||||
void testUpcast() {
|
||||
var setEls = new Set<C>.from(elements);
|
||||
var objectSet = Set.castFrom<C, Object>(setEls);
|
||||
|
||||
Expect.listEquals(elements, objectSet.toList());
|
||||
|
||||
var newObject = new Object();
|
||||
Expect.throws(() => objectSet.add(newObject));
|
||||
Expect.isFalse(objectSet.contains(newObject));
|
||||
|
||||
var toSet = objectSet.toSet();
|
||||
Expect.isTrue(toSet is LinkedHashSet<Object>);
|
||||
Expect.isFalse(toSet is LinkedHashSet<C>);
|
||||
}
|
||||
|
||||
void testNewSet() {
|
||||
// Specified custom newSet as empty HashSet.
|
||||
var setEls = new Set<C>.from(elements);
|
||||
var customNewSet;
|
||||
var objectSet2 = Set.castFrom<C, Object>(setEls,
|
||||
newSet: <T>() => customNewSet = new HashSet<T>());
|
||||
|
||||
var customToSet = objectSet2.toSet();
|
||||
Expect.isTrue(customToSet is HashSet<Object>);
|
||||
Expect.isFalse(customToSet is HashSet<C>);
|
||||
Expect.identical(customToSet, customNewSet);
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
// Copyright (c) 2011, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
library collection.from.test;
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:collection';
|
||||
|
||||
main() {
|
||||
for (Iterable<num> elements in [
|
||||
new Set<num>(),
|
||||
<num>[],
|
||||
const <num>[],
|
||||
const <num, int>{}.keys,
|
||||
const <int, num>{}.values,
|
||||
new Iterable<num>.generate(0),
|
||||
new Set<num>()..add(1)..add(2)..add(4),
|
||||
<num>[1, 2, 4],
|
||||
new Iterable<num>.generate(3, (i) => [1, 2, 4][i]),
|
||||
const <num>[1, 2, 4],
|
||||
const <num, int>{1: 0, 2: 0, 4: 0}.keys,
|
||||
const <int, num>{1: 1, 2: 2, 4: 4}.values,
|
||||
]) {
|
||||
int elementCount = elements.length;
|
||||
check(elements, new List<num>.from(elements));
|
||||
check(elements, new List<int>.from(elements));
|
||||
check(elements, new List<Object>.from(elements));
|
||||
check(elements, new List<num>.from(elements, growable: true));
|
||||
check(elements, new List<int>.from(elements, growable: true));
|
||||
check(elements, new List<Object>.from(elements, growable: true));
|
||||
check(elements, new List<num>.from(elements, growable: false));
|
||||
check(elements, new List<int>.from(elements, growable: false));
|
||||
check(elements, new List<Object>.from(elements, growable: false));
|
||||
check(elements, new Queue<num>.from(elements));
|
||||
check(elements, new Queue<int>.from(elements));
|
||||
check(elements, new Queue<Object>.from(elements));
|
||||
check(elements, new ListQueue<num>.from(elements));
|
||||
check(elements, new ListQueue<int>.from(elements));
|
||||
check(elements, new ListQueue<Object>.from(elements));
|
||||
check(elements, new DoubleLinkedQueue<num>.from(elements));
|
||||
check(elements, new DoubleLinkedQueue<int>.from(elements));
|
||||
check(elements, new DoubleLinkedQueue<Object>.from(elements));
|
||||
check(elements, new Set<num>.from(elements));
|
||||
check(elements, new Set<int>.from(elements));
|
||||
check(elements, new Set<Object>.from(elements));
|
||||
check(elements, new HashSet<num>.from(elements));
|
||||
check(elements, new HashSet<int>.from(elements));
|
||||
check(elements, new HashSet<Object>.from(elements));
|
||||
check(elements, new LinkedHashSet<num>.from(elements));
|
||||
check(elements, new LinkedHashSet<int>.from(elements));
|
||||
check(elements, new LinkedHashSet<Object>.from(elements));
|
||||
check(elements, new SplayTreeSet<num>.from(elements));
|
||||
check(elements, new SplayTreeSet<int>.from(elements));
|
||||
check(elements, new SplayTreeSet<Object>.from(elements));
|
||||
// Sanity check that elements didn't change.
|
||||
Expect.equals(elementCount, elements.length);
|
||||
|
||||
// Lists may be growable or not growable.
|
||||
{
|
||||
var list = new List<num>.from(elements, growable: true);
|
||||
Expect.equals(elementCount, list.length);
|
||||
list.add(42);
|
||||
Expect.equals(elementCount + 1, list.length);
|
||||
}
|
||||
{
|
||||
var list = new List<num>.from(elements);
|
||||
Expect.equals(elementCount, list.length);
|
||||
list.add(42);
|
||||
Expect.equals(elementCount + 1, list.length);
|
||||
}
|
||||
{
|
||||
var list = new List<num>.from(elements, growable: false);
|
||||
Expect.equals(elementCount, list.length);
|
||||
Expect.throwsUnsupportedError(() {
|
||||
list.add(42);
|
||||
});
|
||||
Expect.equals(elementCount, list.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void check(Iterable<num> initial, Iterable other) {
|
||||
Expect.equals(initial.length, other.length);
|
||||
|
||||
for (var element in other) {
|
||||
initial.contains(element);
|
||||
}
|
||||
|
||||
for (var element in initial) {
|
||||
other.contains(element);
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
library map_test;
|
||||
|
||||
import 'dart:collection';
|
||||
|
||||
// Test that length/isEmpty operations are constant time on
|
||||
// maps, strings and collections.
|
||||
|
||||
void testString(int n) {
|
||||
String s = "x";
|
||||
String string = "";
|
||||
int length = n;
|
||||
while (true) {
|
||||
if ((length & 1) == 1) {
|
||||
string += s;
|
||||
}
|
||||
length >>= 1;
|
||||
if (length == 0) break;
|
||||
s += s;
|
||||
}
|
||||
testLength(string, n);
|
||||
testLength(string.codeUnits, n);
|
||||
}
|
||||
|
||||
void testMap(Map map, int n) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
map[i] = i;
|
||||
}
|
||||
testLength(map, n);
|
||||
testLength(map.keys, n);
|
||||
testLength(map.values, n);
|
||||
}
|
||||
|
||||
void testCollection(var collection, n) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
collection.add(i);
|
||||
}
|
||||
testLength(collection, n);
|
||||
}
|
||||
|
||||
void testList(List list, n) {
|
||||
// Works even if list is fixed-length.
|
||||
for (int i = 0; i < n; i++) {
|
||||
list[i] = i;
|
||||
}
|
||||
testLength(list, n);
|
||||
}
|
||||
|
||||
void testLength(var lengthable, int size) {
|
||||
print(lengthable.runtimeType); // Show what hangs the test.
|
||||
int length = 0;
|
||||
// If length, isEmpty or isNotEmpty is not a constant-time (or very fast)
|
||||
// operation, this will timeout.
|
||||
for (int i = 0; i < 100000; i++) {
|
||||
if (!lengthable.isEmpty) length += lengthable.length;
|
||||
if (lengthable.isNotEmpty) length += lengthable.length;
|
||||
}
|
||||
if (length != size * 200000) throw "Bad length: $length / size: $size";
|
||||
}
|
||||
|
||||
main() {
|
||||
const int N = 100000;
|
||||
testMap(new HashMap(), N);
|
||||
testMap(new LinkedHashMap(), N);
|
||||
testMap(new SplayTreeMap(), N);
|
||||
testCollection(new HashSet(), N);
|
||||
testCollection(new LinkedHashSet(), N);
|
||||
testCollection(new ListQueue(), N);
|
||||
testCollection(new DoubleLinkedQueue(), N);
|
||||
testList([]..length = N, N);
|
||||
testList(new List.filled(N, null), N);
|
||||
testString(N);
|
||||
}
|
|
@ -1,86 +0,0 @@
|
|||
// Copyright (c) 2018, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
library collection.from.test;
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:collection';
|
||||
|
||||
main() {
|
||||
for (Iterable<num> elements in [
|
||||
new Set<num>(),
|
||||
<num>[],
|
||||
const <num>[],
|
||||
const <num, int>{}.keys,
|
||||
const <int, num>{}.values,
|
||||
new Iterable<num>.generate(0),
|
||||
new Set<num>()..add(1)..add(2)..add(4),
|
||||
<num>[1, 2, 4],
|
||||
new Iterable<num>.generate(3, (i) => [1, 2, 4][i]),
|
||||
const <num>[1, 2, 4],
|
||||
const <num, int>{1: 0, 2: 0, 4: 0}.keys,
|
||||
const <int, num>{1: 1, 2: 2, 4: 4}.values,
|
||||
]) {
|
||||
String sourceType = elements.runtimeType.toString();
|
||||
check(sourceType, elements, new List<num>.of(elements));
|
||||
Expect.throwsTypeError(() => new List<int>.of(elements));
|
||||
check(sourceType, elements, new List<Object>.of(elements));
|
||||
check(sourceType, elements, new Queue<num>.of(elements));
|
||||
Expect.throwsTypeError(() => new Queue<int>.of(elements));
|
||||
check(sourceType, elements, new Queue<Object>.of(elements));
|
||||
check(sourceType, elements, new ListQueue<num>.of(elements));
|
||||
Expect.throwsTypeError(() => new ListQueue<int>.of(elements));
|
||||
check(sourceType, elements, new ListQueue<Object>.of(elements));
|
||||
check(sourceType, elements, new DoubleLinkedQueue<num>.of(elements));
|
||||
Expect.throwsTypeError(() => new DoubleLinkedQueue<int>.of(elements));
|
||||
check(sourceType, elements, new DoubleLinkedQueue<Object>.of(elements));
|
||||
check(sourceType, elements, new Set<num>.of(elements));
|
||||
Expect.throwsTypeError(() => new Set<int>.of(elements));
|
||||
check(sourceType, elements, new Set<Object>.of(elements));
|
||||
check(sourceType, elements, new HashSet<num>.of(elements));
|
||||
Expect.throwsTypeError(() => new HashSet<int>.of(elements));
|
||||
check(sourceType, elements, new HashSet<Object>.of(elements));
|
||||
check(sourceType, elements, new LinkedHashSet<num>.of(elements));
|
||||
Expect.throwsTypeError(() => new LinkedHashSet<int>.of(elements));
|
||||
check(sourceType, elements, new LinkedHashSet<Object>.of(elements));
|
||||
check(sourceType, elements, new SplayTreeSet<num>.of(elements));
|
||||
Expect.throwsTypeError(() => new SplayTreeSet<int>.of(elements));
|
||||
check(sourceType, elements, new SplayTreeSet<Object>.of(elements));
|
||||
|
||||
// Inference applies to the `of` constructor, unlike the `from` constructor.
|
||||
Expect.isTrue(new List.of(elements) is Iterable<num>);
|
||||
Expect.isTrue(new Queue.of(elements) is Iterable<num>);
|
||||
Expect.isTrue(new ListQueue.of(elements) is Iterable<num>);
|
||||
Expect.isTrue(new DoubleLinkedQueue.of(elements) is Iterable<num>);
|
||||
Expect.isTrue(new Set.of(elements) is Iterable<num>);
|
||||
Expect.isTrue(new HashSet.of(elements) is Iterable<num>);
|
||||
Expect.isTrue(new LinkedHashSet.of(elements) is Iterable<num>);
|
||||
Expect.isTrue(new SplayTreeSet.of(elements) is Iterable<num>);
|
||||
|
||||
Expect.isTrue(new List.of(elements) is! Iterable<int>);
|
||||
Expect.isTrue(new Queue.of(elements) is! Iterable<int>);
|
||||
Expect.isTrue(new ListQueue.of(elements) is! Iterable<int>);
|
||||
Expect.isTrue(new DoubleLinkedQueue.of(elements) is! Iterable<int>);
|
||||
Expect.isTrue(new Set.of(elements) is! Iterable<int>);
|
||||
Expect.isTrue(new HashSet.of(elements) is! Iterable<int>);
|
||||
Expect.isTrue(new LinkedHashSet.of(elements) is! Iterable<int>);
|
||||
Expect.isTrue(new SplayTreeSet.of(elements) is! Iterable<int>);
|
||||
}
|
||||
}
|
||||
|
||||
void check(String sourceType, Iterable<num> source, Iterable target) {
|
||||
String targetType = target.runtimeType.toString();
|
||||
String name = "$sourceType->$targetType";
|
||||
Expect.equals(source.length, target.length, "$name.length");
|
||||
|
||||
for (var element in target) {
|
||||
Expect.isTrue(source.contains(element), "$name:$element in source");
|
||||
}
|
||||
|
||||
for (var element in source) {
|
||||
Expect.isTrue(target.contains(element), "$name:$element in target");
|
||||
}
|
||||
}
|
|
@ -1,132 +0,0 @@
|
|||
// Copyright (c) 2011, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:collection';
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
testRemove(base) {
|
||||
int length = base.length;
|
||||
for (int i = 0; i < length; i++) {
|
||||
Expect.isFalse(base.isEmpty);
|
||||
base.remove(base.first);
|
||||
}
|
||||
Expect.isTrue(base.isEmpty);
|
||||
}
|
||||
|
||||
testRemoveAll(base, Iterable removes) {
|
||||
Set retained = new Set();
|
||||
for (var element in base) {
|
||||
if (!removes.contains(element)) {
|
||||
retained.add(element);
|
||||
}
|
||||
}
|
||||
String name = "$base.removeAll($removes) -> $retained";
|
||||
base.removeAll(removes);
|
||||
for (var value in base) {
|
||||
Expect.isFalse(removes.contains(value), "$name: Found $value");
|
||||
}
|
||||
for (var value in retained) {
|
||||
Expect.isTrue(base.contains(value), "$name: Found $value");
|
||||
}
|
||||
}
|
||||
|
||||
testRetainAll(base, Iterable retains) {
|
||||
Set retained = new Set();
|
||||
for (var element in base) {
|
||||
if (retains.contains(element)) {
|
||||
retained.add(element);
|
||||
}
|
||||
}
|
||||
String name = "$base.retainAll($retains) -> $retained";
|
||||
base.retainAll(retains);
|
||||
for (var value in base) {
|
||||
Expect.isTrue(retains.contains(value), "$name: Found $value");
|
||||
}
|
||||
for (var value in retained) {
|
||||
Expect.isTrue(base.contains(value), "$name: Found $value");
|
||||
}
|
||||
}
|
||||
|
||||
testRemoveWhere(base, bool test(value)) {
|
||||
Set retained = new Set();
|
||||
for (var element in base) {
|
||||
if (!test(element)) {
|
||||
retained.add(element);
|
||||
}
|
||||
}
|
||||
String name = "$base.removeWhere(...) -> $retained";
|
||||
base.removeWhere(test);
|
||||
for (var value in base) {
|
||||
Expect.isFalse(test(value), "$name: Found $value");
|
||||
}
|
||||
for (var value in retained) {
|
||||
Expect.isTrue(base.contains(value), "$name: Found $value");
|
||||
}
|
||||
}
|
||||
|
||||
testRetainWhere(base, bool test(value)) {
|
||||
Set retained = new Set();
|
||||
for (var element in base) {
|
||||
if (test(element)) {
|
||||
retained.add(element);
|
||||
}
|
||||
}
|
||||
String name = "$base.retainWhere(...) -> $retained";
|
||||
base.retainWhere(test);
|
||||
for (var value in base) {
|
||||
Expect.isTrue(test(value), "$name: Found $value");
|
||||
}
|
||||
for (var value in retained) {
|
||||
Expect.isTrue(base.contains(value), "$name: Found $value");
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
var collections = [
|
||||
[],
|
||||
[1],
|
||||
[2],
|
||||
[1, 2],
|
||||
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
||||
[1, 3, 5, 7, 9],
|
||||
[2, 4, 6, 8, 10]
|
||||
];
|
||||
for (var base in collections) {
|
||||
for (var delta in collections) {
|
||||
testRemove(base.toList());
|
||||
testRemove(base.toSet());
|
||||
|
||||
var deltaSet = delta.toSet();
|
||||
testRemoveWhere(base.toList(), deltaSet.contains);
|
||||
testRetainWhere(base.toList(), (e) => !deltaSet.contains(e));
|
||||
|
||||
testRemoveAll(base.toSet(), delta);
|
||||
testRemoveAll(base.toSet(), deltaSet);
|
||||
testRetainAll(base.toSet(), delta);
|
||||
testRetainAll(base.toSet(), deltaSet);
|
||||
testRemoveWhere(base.toSet(), deltaSet.contains);
|
||||
testRetainWhere(base.toSet(), (e) => !deltaSet.contains(e));
|
||||
|
||||
// Test the ListBase class's List implementation.
|
||||
testRemoveWhere(new MyList(base.toList()), deltaSet.contains);
|
||||
testRetainWhere(new MyList(base.toList()), (e) => !deltaSet.contains(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MyList<E> extends ListBase<E> {
|
||||
List<E> _source;
|
||||
MyList(this._source);
|
||||
int get length => _source.length;
|
||||
void set length(int length) {
|
||||
_source.length = length;
|
||||
}
|
||||
|
||||
E operator [](int index) => _source[index];
|
||||
void operator []=(int index, E value) {
|
||||
_source[index] = value;
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
// Copyright (c) 2011, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
library collection_test;
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:collection' show Queue;
|
||||
|
||||
class CollectionTest {
|
||||
CollectionTest(Iterable<int> iterable) {
|
||||
testFold(iterable);
|
||||
}
|
||||
|
||||
void testFold(Iterable<int> iterable) {
|
||||
Expect.equals(
|
||||
28, iterable.fold/*<int>*/(0, (prev, element) => prev + element));
|
||||
Expect.equals(
|
||||
3024, iterable.fold/*<int>*/(1, (prev, element) => prev * element));
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
final TEST_ELEMENTS = const [4, 2, 6, 7, 9];
|
||||
// Const list.
|
||||
new CollectionTest(TEST_ELEMENTS);
|
||||
|
||||
// Fixed size list.
|
||||
var fixedList = new List<int>.filled(TEST_ELEMENTS.length, null);
|
||||
for (int i = 0; i < TEST_ELEMENTS.length; i++) {
|
||||
fixedList[i] = TEST_ELEMENTS[i];
|
||||
}
|
||||
new CollectionTest(fixedList);
|
||||
|
||||
// Growable list.
|
||||
new CollectionTest(new List.from(TEST_ELEMENTS));
|
||||
|
||||
// Set.
|
||||
new CollectionTest(new Set.from(TEST_ELEMENTS));
|
||||
|
||||
// Queue.
|
||||
new CollectionTest(new Queue.from(TEST_ELEMENTS));
|
||||
}
|
|
@ -1,389 +0,0 @@
|
|||
// Copyright (c) 2012, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
/**
|
||||
* Tests for the toString methods on collections and maps.
|
||||
*/
|
||||
|
||||
library collection_to_string;
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:collection' show Queue, LinkedHashMap;
|
||||
import 'dart:math' as Math;
|
||||
|
||||
// TODO(jjb): seed random number generator when API allows it
|
||||
|
||||
const int NUM_TESTS = 300;
|
||||
const int MAX_COLLECTION_SIZE = 7;
|
||||
|
||||
Math.Random rand;
|
||||
|
||||
main() {
|
||||
rand = new Math.Random();
|
||||
smokeTest();
|
||||
exactTest();
|
||||
inexactTest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a few simple examples.
|
||||
*/
|
||||
void smokeTest() {
|
||||
// Non-const lists
|
||||
Expect.equals([].toString(), '[]');
|
||||
Expect.equals([1].toString(), '[1]');
|
||||
Expect.equals(['Elvis'].toString(), '[Elvis]');
|
||||
Expect.equals([null].toString(), '[null]');
|
||||
Expect.equals([1, 2].toString(), '[1, 2]');
|
||||
Expect.equals(['I', 'II'].toString(), '[I, II]');
|
||||
Expect.equals(
|
||||
[
|
||||
[1, 2],
|
||||
[3, 4],
|
||||
[5, 6]
|
||||
].toString(),
|
||||
'[[1, 2], [3, 4], [5, 6]]');
|
||||
|
||||
// Const lists
|
||||
Expect.equals((const []).toString(), '[]');
|
||||
Expect.equals((const [1]).toString(), '[1]');
|
||||
Expect.equals((const ['Elvis']).toString(), '[Elvis]');
|
||||
Expect.equals((const [null]).toString(), '[null]');
|
||||
Expect.equals((const [1, 2]).toString(), '[1, 2]');
|
||||
Expect.equals((const ['I', 'II']).toString(), '[I, II]');
|
||||
Expect.equals(
|
||||
(const [
|
||||
const [1, 2],
|
||||
const [3, 4],
|
||||
const [5, 6]
|
||||
])
|
||||
.toString(),
|
||||
'[[1, 2], [3, 4], [5, 6]]');
|
||||
|
||||
// Non-const maps - Note that all keys are strings; the spec currently demands this
|
||||
Expect.equals({}.toString(), '{}');
|
||||
Expect.equals({'Elvis': 'King'}.toString(), '{Elvis: King}');
|
||||
Expect.equals({'Elvis': null}.toString(), '{Elvis: null}');
|
||||
Expect.equals({'I': 1, 'II': 2}.toString(), '{I: 1, II: 2}');
|
||||
Expect.equals(
|
||||
{
|
||||
'X': {'I': 1, 'II': 2},
|
||||
'Y': {'III': 3, 'IV': 4},
|
||||
'Z': {'V': 5, 'VI': 6}
|
||||
}.toString(),
|
||||
'{X: {I: 1, II: 2}, Y: {III: 3, IV: 4}, Z: {V: 5, VI: 6}}');
|
||||
|
||||
// Const maps
|
||||
Expect.equals(const {}.toString(), '{}');
|
||||
Expect.equals(const {'Elvis': 'King'}.toString(), '{Elvis: King}');
|
||||
Expect.equals({'Elvis': null}.toString(), '{Elvis: null}');
|
||||
Expect.equals(const {'I': 1, 'II': 2}.toString(), '{I: 1, II: 2}');
|
||||
Expect.equals(
|
||||
const {
|
||||
'X': const {'I': 1, 'II': 2},
|
||||
'Y': const {'III': 3, 'IV': 4},
|
||||
'Z': const {'V': 5, 'VI': 6}
|
||||
}.toString(),
|
||||
'{X: {I: 1, II: 2}, Y: {III: 3, IV: 4}, Z: {V: 5, VI: 6}}');
|
||||
}
|
||||
|
||||
// SERIOUS "BASHER" TESTS
|
||||
|
||||
/**
|
||||
* Generate a bunch of random collections (including Maps), and test that
|
||||
* there string form is as expected. The collections include collections
|
||||
* as elements, keys, and values, and include recursive references.
|
||||
*
|
||||
* This test restricts itself to collections with well-defined iteration
|
||||
* orders (i.e., no HashSet, HashMap).
|
||||
*/
|
||||
void exactTest() {
|
||||
for (int i = 0; i < NUM_TESTS; i++) {
|
||||
// Choose a size from 0 to MAX_COLLECTION_SIZE, favoring larger sizes
|
||||
int size =
|
||||
Math.sqrt(random(MAX_COLLECTION_SIZE * MAX_COLLECTION_SIZE)).toInt();
|
||||
|
||||
StringBuffer stringRep = new StringBuffer();
|
||||
Object o = randomCollection(size, stringRep, exact: true);
|
||||
print(stringRep);
|
||||
print(o);
|
||||
Expect.equals(o.toString(), stringRep.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a bunch of random collections (including Maps), and test that
|
||||
* there string form is as expected. The collections include collections
|
||||
* as elements, keys, and values, and include recursive references.
|
||||
*
|
||||
* This test includes collections with ill-defined iteration orders (i.e.,
|
||||
* HashSet, HashMap). As a consequence, it can't use equality tests on the
|
||||
* string form. Instead, it performs equality tests on their "alphagrams."
|
||||
* This might allow false positives, but it does give a fair amount of
|
||||
* confidence.
|
||||
*/
|
||||
void inexactTest() {
|
||||
for (int i = 0; i < NUM_TESTS; i++) {
|
||||
// Choose a size from 0 to MAX_COLLECTION_SIZE, favoring larger sizes
|
||||
int size =
|
||||
Math.sqrt(random(MAX_COLLECTION_SIZE * MAX_COLLECTION_SIZE)).toInt();
|
||||
|
||||
StringBuffer stringRep = new StringBuffer();
|
||||
Object o = randomCollection(size, stringRep, exact: false);
|
||||
print(stringRep);
|
||||
print(o);
|
||||
Expect.equals(alphagram(o.toString()), alphagram(stringRep.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a random collection (or Map) of the specified size, placing its
|
||||
* string representation into the given string buffer.
|
||||
*
|
||||
* If exact is true, the returned collections will not be, and will not contain
|
||||
* a collection with ill-defined iteration order (i.e., a HashSet or HashMap).
|
||||
*/
|
||||
Object randomCollection(int size, StringBuffer stringRep, {bool exact}) {
|
||||
return randomCollectionHelper(size, exact, stringRep, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a random collection (or map) of the specified size, placing its
|
||||
* string representation into the given string buffer. The beingMade
|
||||
* parameter is a list of collections currently under construction, i.e.,
|
||||
* candidates for recursive references.
|
||||
*
|
||||
* If exact is true, the returned collections will not be, and will not contain
|
||||
* a collection with ill-defined iteration order (i.e., a HashSet or HashMap).
|
||||
*/
|
||||
Object randomCollectionHelper(
|
||||
int size, bool exact, StringBuffer stringRep, List beingMade) {
|
||||
double interfaceFrac = rand.nextDouble();
|
||||
|
||||
if (exact) {
|
||||
if (interfaceFrac < 1 / 3) {
|
||||
return randomList(size, exact, stringRep, beingMade);
|
||||
} else if (interfaceFrac < 2 / 3) {
|
||||
return randomQueue(size, exact, stringRep, beingMade);
|
||||
} else {
|
||||
return randomMap(size, exact, stringRep, beingMade);
|
||||
}
|
||||
} else {
|
||||
if (interfaceFrac < 1 / 4) {
|
||||
return randomList(size, exact, stringRep, beingMade);
|
||||
} else if (interfaceFrac < 2 / 4) {
|
||||
return randomQueue(size, exact, stringRep, beingMade);
|
||||
} else if (interfaceFrac < 3 / 4) {
|
||||
return randomSet(size, exact, stringRep, beingMade);
|
||||
} else {
|
||||
return randomMap(size, exact, stringRep, beingMade);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a random List of the specified size, placing its string
|
||||
* representation into the given string buffer. The beingMade
|
||||
* parameter is a list of collections currently under construction, i.e.,
|
||||
* candidates for recursive references.
|
||||
*
|
||||
* If exact is true, the returned collections will not be, and will not contain
|
||||
* a collection with ill-defined iteration order (i.e., a HashSet or HashMap).
|
||||
*/
|
||||
List randomList(int size, bool exact, StringBuffer stringRep, List beingMade) {
|
||||
return populateRandomCollection(size, exact, stringRep, beingMade, [], "[]");
|
||||
}
|
||||
|
||||
/**
|
||||
* Like randomList, but returns a queue.
|
||||
*/
|
||||
Queue randomQueue(
|
||||
int size, bool exact, StringBuffer stringRep, List beingMade) {
|
||||
return populateRandomCollection(
|
||||
size, exact, stringRep, beingMade, new Queue(), "{}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Like randomList, but returns a Set.
|
||||
*/
|
||||
Set randomSet(int size, bool exact, StringBuffer stringRep, List beingMade) {
|
||||
// Until we have LinkedHashSet, method will only be called with exact==true
|
||||
return populateRandomSet(size, exact, stringRep, beingMade, new Set());
|
||||
}
|
||||
|
||||
/**
|
||||
* Like randomList, but returns a map.
|
||||
*/
|
||||
Map randomMap(int size, bool exact, StringBuffer stringRep, List beingMade) {
|
||||
if (exact) {
|
||||
return populateRandomMap(
|
||||
size, exact, stringRep, beingMade, new LinkedHashMap());
|
||||
} else {
|
||||
return populateRandomMap(size, exact, stringRep, beingMade,
|
||||
randomBool() ? new Map() : new LinkedHashMap());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the given empty collection with elements, emitting the string
|
||||
* representation of the collection to stringRep. The beingMade parameter is
|
||||
* a list of collections currently under construction, i.e., candidates for
|
||||
* recursive references.
|
||||
*
|
||||
* If exact is true, the elements of the returned collections will not be,
|
||||
* and will not contain a collection with ill-defined iteration order
|
||||
* (i.e., a HashSet or HashMap).
|
||||
*/
|
||||
populateRandomCollection(int size, bool exact, StringBuffer stringRep,
|
||||
List beingMade, var coll, String delimiters) {
|
||||
beingMade.add(coll);
|
||||
int start = stringRep.length;
|
||||
|
||||
stringRep.write(delimiters[0]);
|
||||
|
||||
List indices = [];
|
||||
for (int i = 0; i < size; i++) {
|
||||
indices.add(stringRep.length);
|
||||
if (i != 0) stringRep.write(', ');
|
||||
coll.add(randomElement(random(size), exact, stringRep, beingMade));
|
||||
}
|
||||
if (size > 5 && delimiters == "()") {
|
||||
const int MAX_LENGTH = 80;
|
||||
const int MIN_COUNT = 3;
|
||||
const int MAX_COUNT = 100;
|
||||
// It's an iterable, it may omit some elements.
|
||||
int end = stringRep.length;
|
||||
if (size > MAX_COUNT) {
|
||||
// Last two elements are also omitted, just find the first three or
|
||||
// first 60 characters.
|
||||
for (int i = MIN_COUNT; i < size; i++) {
|
||||
int startIndex = indices[i];
|
||||
if (startIndex - start > MAX_LENGTH - 6) {
|
||||
// Limit - ", ...)".length.
|
||||
String prefix = stringRep.toString().substring(0, startIndex);
|
||||
stringRep.clear();
|
||||
stringRep.write(prefix);
|
||||
stringRep.write(", ...");
|
||||
}
|
||||
}
|
||||
} else if (stringRep.length - start > MAX_LENGTH - 1) {
|
||||
// 80 - ")".length.
|
||||
// Last two elements are always included. Middle ones may be omitted.
|
||||
int lastTwoLength = end - indices[indices.length - 2];
|
||||
// Try to find first element to omit.
|
||||
for (int i = 3; i <= size - 3; i++) {
|
||||
int elementEnd = indices[i + 1];
|
||||
int lengthAfter = elementEnd - start;
|
||||
int ellipsisSize = 5; // ", ...".length
|
||||
if (i == size - 3) ellipsisSize = 0; // No ellipsis if we hit the end.
|
||||
if (lengthAfter + ellipsisSize + lastTwoLength > MAX_LENGTH - 1) {
|
||||
// Omit this element and everything up to the last two.
|
||||
int elementStart = indices[i];
|
||||
// Rewrite string buffer by copying it out, clearing, and putting
|
||||
// the parts back in.
|
||||
String buffer = stringRep.toString();
|
||||
String prefix = buffer.substring(0, elementStart);
|
||||
String suffix = buffer.substring(end - lastTwoLength, end);
|
||||
stringRep.clear();
|
||||
stringRep.write(prefix);
|
||||
stringRep.write(", ...");
|
||||
stringRep.write(suffix);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stringRep.write(delimiters[1]);
|
||||
beingMade.removeLast();
|
||||
return coll;
|
||||
}
|
||||
|
||||
/** Like populateRandomCollection, but for sets (elements must be hashable) */
|
||||
Set populateRandomSet(
|
||||
int size, bool exact, StringBuffer stringRep, List beingMade, Set set) {
|
||||
stringRep.write('{');
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (i != 0) stringRep.write(', ');
|
||||
set.add(i);
|
||||
stringRep.write(i);
|
||||
}
|
||||
|
||||
stringRep.write('}');
|
||||
return set;
|
||||
}
|
||||
|
||||
/** Like populateRandomCollection, but for maps. */
|
||||
Map populateRandomMap(
|
||||
int size, bool exact, StringBuffer stringRep, List beingMade, Map map) {
|
||||
beingMade.add(map);
|
||||
stringRep.write('{');
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (i != 0) stringRep.write(', ');
|
||||
|
||||
int key = i; // Ensures no duplicates
|
||||
stringRep.write(key);
|
||||
stringRep.write(': ');
|
||||
Object val = randomElement(random(size), exact, stringRep, beingMade);
|
||||
map[key] = val;
|
||||
}
|
||||
|
||||
stringRep.write('}');
|
||||
beingMade.removeLast();
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a random element which can be an int, a collection, or a map,
|
||||
* and emits it to StringRep. The beingMade parameter is a list of collections
|
||||
* currently under construction, i.e., candidates for recursive references.
|
||||
*
|
||||
* If exact is true, the returned element will not be, and will not contain
|
||||
* a collection with ill-defined iteration order (i.e., a HashSet or HashMap).
|
||||
*/
|
||||
Object randomElement(
|
||||
int size, bool exact, StringBuffer stringRep, List beingMade) {
|
||||
Object result;
|
||||
double elementTypeFrac = rand.nextDouble();
|
||||
if (elementTypeFrac < 1 / 3) {
|
||||
result = random(1000);
|
||||
stringRep.write(result);
|
||||
} else if (elementTypeFrac < 2 / 3) {
|
||||
// Element is a random (new) collection
|
||||
result = randomCollectionHelper(size, exact, stringRep, beingMade);
|
||||
} else {
|
||||
// Element is a random recursive ref
|
||||
result = beingMade[random(beingMade.length)];
|
||||
if (result is List) {
|
||||
stringRep.write('[...]');
|
||||
} else if (result is Set || result is Map || result is Queue) {
|
||||
stringRep.write('{...}');
|
||||
} else {
|
||||
stringRep.write('(...)');
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Returns a random int on [0, max) */
|
||||
int random(int max) {
|
||||
return rand.nextInt(max);
|
||||
}
|
||||
|
||||
/** Returns a random boolean value. */
|
||||
bool randomBool() {
|
||||
return rand.nextBool();
|
||||
}
|
||||
|
||||
/** Returns the alphabetized characters in a string. */
|
||||
String alphagram(String s) {
|
||||
// Calling [toList] to convert unmodifiable list to normal list.
|
||||
List<int> chars = s.codeUnits.toList();
|
||||
chars.sort((int a, int b) => a - b);
|
||||
return new String.fromCharCodes(chars);
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
// Copyright (c) 2012, 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.
|
||||
// Dart test for testing Math.min and Math.max.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
negate(x) => -x;
|
||||
|
||||
main() {
|
||||
// Test matrix:
|
||||
var minNonZero = 5e-324;
|
||||
var maxDenormal = 2.225073858507201e-308;
|
||||
var minNormal = 2.2250738585072014e-308;
|
||||
var maxFraction = 0.9999999999999999;
|
||||
var minAbove1 = 1.0000000000000002;
|
||||
var maxNonInt = 4503599627370495.5;
|
||||
var maxNonIntFloorAsInt = maxNonInt.floor();
|
||||
var maxNonIntFloorAsDouble = maxNonIntFloorAsInt.toDouble();
|
||||
var maxExactIntAsDouble = 9007199254740992.0;
|
||||
var maxExactIntAsInt = 9007199254740992;
|
||||
var two53 = 1 << 53; // Same as maxExactIntAsInt.
|
||||
var two53p1 = two53 + 1;
|
||||
var maxFiniteAsDouble = 1.7976931348623157e+308;
|
||||
var maxFiniteAsInt = maxFiniteAsDouble.truncate();
|
||||
var inf = double.infinity;
|
||||
var nan = double.nan;
|
||||
var mnan = negate(nan);
|
||||
var minInt64 = -0x8000000000000000;
|
||||
var minInt64AsDouble = minInt64.toDouble();
|
||||
var maxInt64 = 0x7fffffffffffffff;
|
||||
var maxInt64AsDouble = maxInt64.toDouble(); // 1 << 63
|
||||
var matrix = [
|
||||
-inf,
|
||||
-maxFiniteAsDouble,
|
||||
[minInt64, minInt64AsDouble],
|
||||
[-maxInt64, -maxFiniteAsInt],
|
||||
-two53p1,
|
||||
[-two53, -maxExactIntAsInt, -maxExactIntAsDouble],
|
||||
-maxNonInt,
|
||||
[-maxNonIntFloorAsDouble, -maxNonIntFloorAsInt],
|
||||
[-499.0, -499],
|
||||
-minAbove1,
|
||||
[-1.0, -1],
|
||||
-maxFraction,
|
||||
-minNormal,
|
||||
-maxDenormal,
|
||||
-minNonZero,
|
||||
-0.0,
|
||||
[0, 0, 0],
|
||||
minNonZero,
|
||||
maxDenormal,
|
||||
minNormal,
|
||||
maxFraction,
|
||||
[1.0, 1],
|
||||
minAbove1,
|
||||
[499.0, 499],
|
||||
[maxNonIntFloorAsDouble, maxNonIntFloorAsInt],
|
||||
maxNonInt,
|
||||
[two53, maxExactIntAsInt, maxExactIntAsDouble],
|
||||
two53p1,
|
||||
[maxInt64, maxFiniteAsInt],
|
||||
maxInt64AsDouble,
|
||||
maxFiniteAsDouble,
|
||||
inf,
|
||||
[nan, mnan],
|
||||
];
|
||||
|
||||
check(left, right, expectedResult) {
|
||||
if (left is List) {
|
||||
for (var x in left) check(x, right, expectedResult);
|
||||
return;
|
||||
}
|
||||
if (right is List) {
|
||||
for (var x in right) check(left, x, expectedResult);
|
||||
return;
|
||||
}
|
||||
int actual = left.compareTo(right);
|
||||
Expect.equals(
|
||||
expectedResult,
|
||||
actual,
|
||||
"($left).compareTo($right) failed "
|
||||
"(should have been $expectedResult, was $actual");
|
||||
}
|
||||
|
||||
for (int i = 0; i < matrix.length; i++) {
|
||||
for (int j = 0; j < matrix.length; j++) {
|
||||
var left = matrix[i];
|
||||
var right = matrix[j];
|
||||
if (left is List) {
|
||||
check(left, left, 0);
|
||||
}
|
||||
check(left, right, i == j ? 0 : (i < j ? -1 : 1));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,138 +0,0 @@
|
|||
// Copyright (c) 2012, 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.
|
||||
// Dart test for testing Math.min and Math.max.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
negate(x) => -x;
|
||||
|
||||
main() {
|
||||
// Test matrix:
|
||||
// -inf < -499.0 == -499 < -0.0 < 0.0 == 0 < 499.0 == 499 < +inf < -NaN, NaN.
|
||||
var inf = double.infinity;
|
||||
var nan = double.nan;
|
||||
var mnan = negate(nan);
|
||||
|
||||
Expect.equals(0, (-inf).compareTo(-inf));
|
||||
Expect.equals(-1, (-inf).compareTo(-499.0));
|
||||
Expect.equals(-1, (-inf).compareTo(-499));
|
||||
Expect.equals(-1, (-inf).compareTo(-0.0));
|
||||
Expect.equals(-1, (-inf).compareTo(0));
|
||||
Expect.equals(-1, (-inf).compareTo(0.0));
|
||||
Expect.equals(-1, (-inf).compareTo(499.0));
|
||||
Expect.equals(-1, (-inf).compareTo(499));
|
||||
Expect.equals(-1, (-inf).compareTo(inf));
|
||||
Expect.equals(-1, (-inf).compareTo(nan));
|
||||
Expect.equals(-1, (-inf).compareTo(mnan));
|
||||
|
||||
Expect.equals(1, (-499.0).compareTo(-inf));
|
||||
Expect.equals(0, (-499.0).compareTo(-499.0));
|
||||
Expect.equals(0, (-499.0).compareTo(-499));
|
||||
Expect.equals(-1, (-499.0).compareTo(-0.0));
|
||||
Expect.equals(-1, (-499.0).compareTo(0));
|
||||
Expect.equals(-1, (-499.0).compareTo(0.0));
|
||||
Expect.equals(-1, (-499.0).compareTo(499.0));
|
||||
Expect.equals(-1, (-499.0).compareTo(499));
|
||||
Expect.equals(-1, (-499.0).compareTo(inf));
|
||||
Expect.equals(-1, (-499.0).compareTo(nan));
|
||||
Expect.equals(-1, (-499.0).compareTo(mnan));
|
||||
|
||||
Expect.equals(1, (-499).compareTo(-inf));
|
||||
Expect.equals(0, (-499).compareTo(-499.0));
|
||||
Expect.equals(0, (-499).compareTo(-499));
|
||||
Expect.equals(-1, (-499).compareTo(-0.0));
|
||||
Expect.equals(-1, (-499).compareTo(0));
|
||||
Expect.equals(-1, (-499).compareTo(0.0));
|
||||
Expect.equals(-1, (-499).compareTo(499.0));
|
||||
Expect.equals(-1, (-499).compareTo(499));
|
||||
Expect.equals(-1, (-499).compareTo(inf));
|
||||
Expect.equals(-1, (-499).compareTo(nan));
|
||||
Expect.equals(-1, (-499).compareTo(mnan));
|
||||
|
||||
Expect.equals(1, (-0.0).compareTo(-inf));
|
||||
Expect.equals(1, (-0.0).compareTo(-499.0));
|
||||
Expect.equals(1, (-0.0).compareTo(-499));
|
||||
Expect.equals(0, (-0.0).compareTo(-0.0));
|
||||
Expect.equals(-1, (-0.0).compareTo(0));
|
||||
Expect.equals(-1, (-0.0).compareTo(0.0));
|
||||
Expect.equals(-1, (-0.0).compareTo(499.0));
|
||||
Expect.equals(-1, (-0.0).compareTo(499));
|
||||
Expect.equals(-1, (-0.0).compareTo(inf));
|
||||
Expect.equals(-1, (-0.0).compareTo(nan));
|
||||
Expect.equals(-1, (-0.0).compareTo(mnan));
|
||||
|
||||
Expect.equals(1, (0).compareTo(-inf));
|
||||
Expect.equals(1, (0).compareTo(-499.0));
|
||||
Expect.equals(1, (0).compareTo(-499));
|
||||
Expect.equals(1, (0).compareTo(-0.0));
|
||||
Expect.equals(0, (0).compareTo(0));
|
||||
Expect.equals(0, (0).compareTo(0.0));
|
||||
Expect.equals(-1, (0).compareTo(499.0));
|
||||
Expect.equals(-1, (0).compareTo(499));
|
||||
Expect.equals(-1, (0).compareTo(inf));
|
||||
Expect.equals(-1, (0).compareTo(nan));
|
||||
Expect.equals(-1, (0).compareTo(mnan));
|
||||
|
||||
Expect.equals(1, (0.0).compareTo(-inf));
|
||||
Expect.equals(1, (0.0).compareTo(-499.0));
|
||||
Expect.equals(1, (0.0).compareTo(-499));
|
||||
Expect.equals(1, (0.0).compareTo(-0.0));
|
||||
Expect.equals(0, (0.0).compareTo(0));
|
||||
Expect.equals(0, (0.0).compareTo(0.0));
|
||||
Expect.equals(-1, (0.0).compareTo(499.0));
|
||||
Expect.equals(-1, (0.0).compareTo(499));
|
||||
Expect.equals(-1, (0.0).compareTo(inf));
|
||||
Expect.equals(-1, (0.0).compareTo(nan));
|
||||
Expect.equals(-1, (0.0).compareTo(mnan));
|
||||
|
||||
Expect.equals(1, (499.0).compareTo(-inf));
|
||||
Expect.equals(1, (499.0).compareTo(-499.0));
|
||||
Expect.equals(1, (499.0).compareTo(-499));
|
||||
Expect.equals(1, (499.0).compareTo(-0.0));
|
||||
Expect.equals(1, (499.0).compareTo(0));
|
||||
Expect.equals(1, (499.0).compareTo(0.0));
|
||||
Expect.equals(0, (499.0).compareTo(499.0));
|
||||
Expect.equals(0, (499.0).compareTo(499));
|
||||
Expect.equals(-1, (499.0).compareTo(inf));
|
||||
Expect.equals(-1, (499.0).compareTo(nan));
|
||||
Expect.equals(-1, (499.0).compareTo(mnan));
|
||||
|
||||
Expect.equals(1, (499).compareTo(-inf));
|
||||
Expect.equals(1, (499).compareTo(-499.0));
|
||||
Expect.equals(1, (499).compareTo(-499));
|
||||
Expect.equals(1, (499).compareTo(-0.0));
|
||||
Expect.equals(1, (499).compareTo(0));
|
||||
Expect.equals(1, (499).compareTo(0.0));
|
||||
Expect.equals(0, (499).compareTo(499.0));
|
||||
Expect.equals(0, (499).compareTo(499));
|
||||
Expect.equals(-1, (499).compareTo(inf));
|
||||
Expect.equals(-1, (499).compareTo(nan));
|
||||
Expect.equals(-1, (499).compareTo(mnan));
|
||||
|
||||
Expect.equals(1, inf.compareTo(-inf));
|
||||
Expect.equals(1, inf.compareTo(-499.0));
|
||||
Expect.equals(1, inf.compareTo(-499));
|
||||
Expect.equals(1, inf.compareTo(-0.0));
|
||||
Expect.equals(1, inf.compareTo(0));
|
||||
Expect.equals(1, inf.compareTo(0.0));
|
||||
Expect.equals(1, inf.compareTo(499.0));
|
||||
Expect.equals(1, inf.compareTo(499));
|
||||
Expect.equals(0, inf.compareTo(inf));
|
||||
Expect.equals(-1, inf.compareTo(nan));
|
||||
Expect.equals(-1, inf.compareTo(mnan));
|
||||
|
||||
Expect.equals(1, nan.compareTo(-inf));
|
||||
Expect.equals(1, nan.compareTo(-499.0));
|
||||
Expect.equals(1, nan.compareTo(-499));
|
||||
Expect.equals(1, nan.compareTo(-0.0));
|
||||
Expect.equals(1, nan.compareTo(0));
|
||||
Expect.equals(1, nan.compareTo(0.0));
|
||||
Expect.equals(1, nan.compareTo(499.0));
|
||||
Expect.equals(1, nan.compareTo(499));
|
||||
Expect.equals(1, nan.compareTo(inf));
|
||||
Expect.equals(0, nan.compareTo(nan));
|
||||
Expect.equals(0, nan.compareTo(mnan));
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
// Copyright (c) 2011, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
// Test that a final list literal is not expandable nor modifiable.
|
||||
|
||||
class ConstListLiteralTest {
|
||||
static void testMain() {
|
||||
var list = const [4, 2, 3];
|
||||
Expect.equals(3, list.length);
|
||||
|
||||
var exception = null;
|
||||
try {
|
||||
list.add(4);
|
||||
} on UnsupportedError catch (e) {
|
||||
exception = e;
|
||||
}
|
||||
Expect.equals(true, exception != null);
|
||||
Expect.equals(3, list.length);
|
||||
exception = null;
|
||||
|
||||
exception = null;
|
||||
try {
|
||||
list.addAll([4, 5]);
|
||||
} on UnsupportedError catch (e) {
|
||||
exception = e;
|
||||
}
|
||||
Expect.equals(true, exception != null);
|
||||
Expect.equals(3, list.length);
|
||||
|
||||
exception = null;
|
||||
try {
|
||||
list[0] = 0;
|
||||
} on UnsupportedError catch (e) {
|
||||
exception = e;
|
||||
}
|
||||
Expect.equals(true, exception != null);
|
||||
Expect.equals(3, list.length);
|
||||
|
||||
exception = null;
|
||||
try {
|
||||
list.sort((a, b) => a - b);
|
||||
} on UnsupportedError catch (e) {
|
||||
exception = e;
|
||||
}
|
||||
Expect.equals(true, exception != null);
|
||||
Expect.equals(3, list.length);
|
||||
Expect.equals(4, list[0]);
|
||||
Expect.equals(2, list[1]);
|
||||
Expect.equals(3, list[2]);
|
||||
|
||||
exception = null;
|
||||
try {
|
||||
list.setRange(0, 1, [1], 0);
|
||||
} on UnsupportedError catch (e) {
|
||||
exception = e;
|
||||
}
|
||||
Expect.equals(true, exception != null);
|
||||
Expect.equals(3, list.length);
|
||||
Expect.equals(4, list[0]);
|
||||
Expect.equals(2, list[1]);
|
||||
Expect.equals(3, list[2]);
|
||||
|
||||
// Note: the next check is a regression test for dart2js. The immutable list
|
||||
// overrides the 'length' property of List, but relies on using the native
|
||||
// 'forEach' construct in Array. This test ensures that our strategy works
|
||||
// correctly.
|
||||
int x = 0;
|
||||
list.forEach((e) {
|
||||
x += e;
|
||||
});
|
||||
Expect.equals(9, x);
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
ConstListLiteralTest.testMain();
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
// Copyright (c) 2011, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
main() {
|
||||
testImmutable(const []);
|
||||
testImmutable(const [1]);
|
||||
testImmutable(const [1, 2]);
|
||||
}
|
||||
|
||||
testImmutable(var list) {
|
||||
Expect.throwsUnsupportedError(() => list.removeRange(0, 0));
|
||||
Expect.throwsUnsupportedError(() => list.removeRange(0, 1));
|
||||
Expect.throwsUnsupportedError(() => list.removeRange(-1, 1));
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
// Copyright (c) 2011, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
main() {
|
||||
testImmutable(const []);
|
||||
testImmutable(const [1]);
|
||||
testImmutable(const [1, 2]);
|
||||
}
|
||||
|
||||
testImmutable(List list) {
|
||||
Expect.throwsUnsupportedError(() => list.setRange(0, 0, const []));
|
||||
Expect.throwsUnsupportedError(() => list.setRange(0, 1, const [], 1));
|
||||
Expect.throwsUnsupportedError(() => list.setRange(0, 1, const []));
|
||||
Expect.throwsUnsupportedError(() => list.setRange(0, 0, []));
|
||||
Expect.throwsUnsupportedError(() => list.setRange(0, 1, [], 1));
|
||||
Expect.throwsUnsupportedError(() => list.setRange(0, 1, []));
|
||||
Expect.throwsUnsupportedError(() => list.setRange(0, 0, const [1]));
|
||||
Expect.throwsUnsupportedError(() => list.setRange(0, 1, const [1]));
|
||||
Expect.throwsUnsupportedError(() => list.setRange(0, 0, [1]));
|
||||
Expect.throwsUnsupportedError(() => list.setRange(0, 1, [1]));
|
||||
Expect.throwsUnsupportedError(() => list.setRange(0, 1, [1], 1));
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
// Copyright (c) 2011, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
/**
|
||||
* Verify static compilation errors on strings and lists.
|
||||
*/
|
||||
class CoreStaticTypesTest {
|
||||
static testMain() {
|
||||
testStringOperators();
|
||||
testStringMethods();
|
||||
testListOperators();
|
||||
}
|
||||
|
||||
static testStringOperators() {
|
||||
var q = "abcdef";
|
||||
q['hello'];
|
||||
//^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
|
||||
// [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
|
||||
q[0] = 'x';
|
||||
// ^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_OPERATOR
|
||||
// [cfe] The operator '[]=' isn't defined for the class 'String'.
|
||||
}
|
||||
|
||||
static testStringMethods() {
|
||||
var s = "abcdef";
|
||||
s.startsWith(1);
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
|
||||
// [cfe] The argument type 'int' can't be assigned to the parameter type 'Pattern'.
|
||||
s.endsWith(1);
|
||||
// ^
|
||||
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
|
||||
// [cfe] The argument type 'int' can't be assigned to the parameter type 'String'.
|
||||
}
|
||||
|
||||
static testListOperators() {
|
||||
var a = [1, 2, 3, 4];
|
||||
a['0'];
|
||||
//^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
|
||||
// [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
|
||||
a['0'] = 99;
|
||||
//^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.ARGUMENT_TYPE_NOT_ASSIGNABLE
|
||||
// [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
CoreStaticTypesTest.testMain();
|
||||
}
|
|
@ -1,337 +0,0 @@
|
|||
// Copyright (c) 2011, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
/**
|
||||
* A test of simple runtime behavior on numbers, strings and lists with
|
||||
* a focus on both correct behavior and runtime errors.
|
||||
*
|
||||
* This file is written to use minimal type declarations to match a
|
||||
* typical dynamic language coding style.
|
||||
*/
|
||||
class CoreRuntimeTypesTest {
|
||||
static testMain() {
|
||||
testBooleanOperators();
|
||||
testRationalOperators();
|
||||
testIntegerOperators();
|
||||
testOperatorErrors();
|
||||
testRationalMethods();
|
||||
testIntegerMethods();
|
||||
testStringOperators();
|
||||
testStringMethods();
|
||||
testListOperators();
|
||||
testListMethods();
|
||||
testMapOperators();
|
||||
testMapMethods();
|
||||
testLiterals();
|
||||
testDateMethods();
|
||||
}
|
||||
|
||||
static assertEquals(a, b) {
|
||||
Expect.equals(b, a);
|
||||
}
|
||||
|
||||
static assertListEquals(List a, List b) {
|
||||
Expect.equals(b.length, a.length);
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Expect.equals(b[i], a[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static assertListContains(List a, List b) {
|
||||
a.sort((x, y) => x.compareTo(y));
|
||||
b.sort((x, y) => x.compareTo(y));
|
||||
assertListEquals(a, b);
|
||||
}
|
||||
|
||||
static assertTypeError(void f(), [String message]) {
|
||||
Expect.throws<Error>(
|
||||
f,
|
||||
(exception) =>
|
||||
(exception is TypeError) ||
|
||||
(exception is AssertionError) ||
|
||||
(exception is NoSuchMethodError) ||
|
||||
(exception is ArgumentError),
|
||||
message);
|
||||
}
|
||||
|
||||
static testBooleanOperators() {
|
||||
var x = true, y = false;
|
||||
assertEquals(x, true);
|
||||
assertEquals(y, false);
|
||||
assertEquals(x, !y);
|
||||
assertEquals(!x, y);
|
||||
}
|
||||
|
||||
static testRationalOperators() {
|
||||
var x = 10, y = 20;
|
||||
assertEquals(x + y, 30);
|
||||
assertEquals(x - y, -10);
|
||||
assertEquals(x * y, 200);
|
||||
assertEquals(x / y, 0.5);
|
||||
assertEquals(x ~/ y, 0);
|
||||
assertEquals(x % y, 10);
|
||||
}
|
||||
|
||||
static testIntegerOperators() {
|
||||
var x = 18, y = 17;
|
||||
assertEquals(x | y, 19);
|
||||
assertEquals(x & y, 16);
|
||||
assertEquals(x ^ y, 3);
|
||||
assertEquals(2 >> 1, 1);
|
||||
assertEquals(1 << 1, 2);
|
||||
}
|
||||
|
||||
static testOperatorErrors() {
|
||||
var objs = [
|
||||
1,
|
||||
'2',
|
||||
[3],
|
||||
null,
|
||||
true,
|
||||
new Map()
|
||||
];
|
||||
for (var i = 0; i < objs.length; i++) {
|
||||
for (var j = i + 1; j < objs.length; j++) {
|
||||
testBinaryOperatorErrors(objs[i], objs[j]);
|
||||
testBinaryOperatorErrors(objs[j], objs[i]);
|
||||
}
|
||||
testUnaryOperatorErrors(objs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static testBinaryOperatorErrors(x, y) {
|
||||
assertTypeError(() {
|
||||
x + y;
|
||||
}, "$x+$y");
|
||||
assertTypeError(() {
|
||||
x - y;
|
||||
}, "$x-$y");
|
||||
// String.* is the only non-same-type binary operator we have.
|
||||
if (x is! String && y is! int) {
|
||||
assertTypeError(() {
|
||||
x * y;
|
||||
}, "$x*$y");
|
||||
}
|
||||
assertTypeError(() {
|
||||
x / y;
|
||||
}, "$x/$y");
|
||||
assertTypeError(() {
|
||||
x | y;
|
||||
}, "$x|$y");
|
||||
assertTypeError(() {
|
||||
x ^ y;
|
||||
}, "$x^$y");
|
||||
assertTypeError(() {
|
||||
x & y;
|
||||
}, "$x&$y");
|
||||
assertTypeError(() {
|
||||
x << y;
|
||||
}, "$x<<$y");
|
||||
assertTypeError(() {
|
||||
x >> y;
|
||||
}, "$x>>$y");
|
||||
assertTypeError(() {
|
||||
x ~/ y;
|
||||
}, "$x~/$y");
|
||||
assertTypeError(() {
|
||||
x % y;
|
||||
}, "$x%$y");
|
||||
|
||||
testComparisonOperatorErrors(x, y);
|
||||
}
|
||||
|
||||
static testComparisonOperatorErrors(x, y) {
|
||||
assertEquals(x == y, false);
|
||||
assertEquals(x != y, true);
|
||||
assertTypeError(() {
|
||||
x < y;
|
||||
}, "$x<$y");
|
||||
assertTypeError(() {
|
||||
x <= y;
|
||||
}, "$x<=$y");
|
||||
assertTypeError(() {
|
||||
x > y;
|
||||
}, "$x>$y");
|
||||
assertTypeError(() {
|
||||
x >= y;
|
||||
}, "$x>=$y");
|
||||
}
|
||||
|
||||
static testUnaryOperatorErrors(x) {
|
||||
if (x is! int) {
|
||||
assertTypeError(() {
|
||||
~x;
|
||||
}, "~$x");
|
||||
}
|
||||
if (x is! num) {
|
||||
assertTypeError(() {
|
||||
-x;
|
||||
}, "-$x");
|
||||
}
|
||||
if (x is! bool) {
|
||||
assertTypeError(() {
|
||||
!x;
|
||||
}, "!$x");
|
||||
}
|
||||
}
|
||||
|
||||
static testRationalMethods() {
|
||||
var x = 10.6;
|
||||
assertEquals(x.abs(), 10.6);
|
||||
assertEquals((-x).abs(), 10.6);
|
||||
assertEquals(x.round(), 11);
|
||||
assertEquals(x.floor(), 10);
|
||||
assertEquals(x.ceil(), 11);
|
||||
}
|
||||
|
||||
// TODO(jimhug): Determine correct behavior for mixing ints and floats.
|
||||
static testIntegerMethods() {
|
||||
var y = 9;
|
||||
assertEquals(y.isEven, false);
|
||||
assertEquals(y.isOdd, true);
|
||||
assertEquals(y.toRadixString(2), '1001');
|
||||
assertEquals(y.toRadixString(3), '100');
|
||||
assertEquals(y.toRadixString(16), '9');
|
||||
assertEquals((0).toRadixString(16), '0');
|
||||
try {
|
||||
y.toRadixString(0);
|
||||
Expect.fail("Illegal radix 0 accepted.");
|
||||
} catch (e) {}
|
||||
try {
|
||||
y.toRadixString(-1);
|
||||
Expect.fail("Illegal radix -1 accepted.");
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
static testStringOperators() {
|
||||
var s = "abcdef";
|
||||
assertEquals(s, "abcdef");
|
||||
assertEquals(s.codeUnitAt(0), 97);
|
||||
assertEquals(s[0], 'a');
|
||||
assertEquals(s.length, 6);
|
||||
assertTypeError(() {
|
||||
s[null];
|
||||
});
|
||||
}
|
||||
|
||||
// TODO(jimhug): Fill out full set of string methods.
|
||||
static testStringMethods() {
|
||||
var s = "abcdef";
|
||||
assertEquals(s.isEmpty, false);
|
||||
assertEquals(s.isNotEmpty, true);
|
||||
assertEquals(s.startsWith("abc"), true);
|
||||
assertEquals(s.endsWith("def"), true);
|
||||
assertEquals(s.startsWith("aa"), false);
|
||||
assertEquals(s.endsWith("ff"), false);
|
||||
assertEquals(s.contains('cd', 0), true);
|
||||
assertEquals(s.contains('cd', 2), true);
|
||||
assertEquals(s.contains('cd', 3), false);
|
||||
assertEquals(s.indexOf('cd', 2), 2);
|
||||
assertEquals(s.indexOf('cd', 3), -1);
|
||||
}
|
||||
|
||||
static testListOperators() {
|
||||
var a = [1, 2, 3, 4];
|
||||
assertEquals(a[0], 1);
|
||||
a[0] = 42;
|
||||
assertEquals(a[0], 42);
|
||||
assertEquals(a.length, 4);
|
||||
}
|
||||
|
||||
// TODO(jimhug): Fill out full set of list methods.
|
||||
static testListMethods() {
|
||||
var a = [1, 2, 3, 4];
|
||||
assertEquals(a.isEmpty, false);
|
||||
assertEquals(a.length, 4);
|
||||
var exception = null;
|
||||
a.clear();
|
||||
assertEquals(a.length, 0);
|
||||
}
|
||||
|
||||
static testMapOperators() {
|
||||
var d = new Map();
|
||||
d['a'] = 1;
|
||||
d['b'] = 2;
|
||||
assertEquals(d['a'], 1);
|
||||
assertEquals(d['b'], 2);
|
||||
assertEquals(d['c'], null);
|
||||
}
|
||||
|
||||
static testMapMethods() {
|
||||
var d = new Map();
|
||||
d['a'] = 1;
|
||||
d['b'] = 2;
|
||||
assertEquals(d.containsValue(2), true);
|
||||
assertEquals(d.containsValue(3), false);
|
||||
assertEquals(d.containsKey('a'), true);
|
||||
assertEquals(d.containsKey('c'), false);
|
||||
assertEquals(d.keys.length, 2);
|
||||
assertEquals(d.values.length, 2);
|
||||
|
||||
assertEquals(d.remove('c'), null);
|
||||
assertEquals(d.remove('b'), 2);
|
||||
assertEquals(d.keys.single, 'a');
|
||||
assertEquals(d.values.single, 1);
|
||||
|
||||
d['c'] = 3;
|
||||
d['f'] = 4;
|
||||
assertEquals(d.keys.length, 3);
|
||||
assertEquals(d.values.length, 3);
|
||||
assertListContains(d.keys.toList(), ['a', 'c', 'f']);
|
||||
assertListContains(d.values.toList(), [1, 3, 4]);
|
||||
|
||||
var count = 0;
|
||||
d.forEach((key, value) {
|
||||
count++;
|
||||
assertEquals(value, d[key]);
|
||||
});
|
||||
assertEquals(count, 3);
|
||||
|
||||
d = {'a': 1, 'b': 2};
|
||||
assertEquals(d.containsValue(2), true);
|
||||
assertEquals(d.containsValue(3), false);
|
||||
assertEquals(d.containsKey('a'), true);
|
||||
assertEquals(d.containsKey('c'), false);
|
||||
assertEquals(d.keys.length, 2);
|
||||
assertEquals(d.values.length, 2);
|
||||
|
||||
d['g'] = null;
|
||||
assertEquals(d.containsKey('g'), true);
|
||||
assertEquals(d['g'], null);
|
||||
}
|
||||
|
||||
static testDateMethods() {
|
||||
var msec = 115201000;
|
||||
var d = new DateTime.fromMillisecondsSinceEpoch(msec, isUtc: true);
|
||||
assertEquals(d.second, 1);
|
||||
assertEquals(d.year, 1970);
|
||||
|
||||
d = new DateTime.now();
|
||||
assertEquals(d.year >= 1970, true);
|
||||
}
|
||||
|
||||
static testLiterals() {
|
||||
true.toString();
|
||||
1.0.toString();
|
||||
.5.toString();
|
||||
1.toString();
|
||||
if (false) {
|
||||
// Depends on http://b/4198808.
|
||||
null.toString();
|
||||
}
|
||||
'${null}'.toString();
|
||||
'${true}'.toString();
|
||||
'${false}'.toString();
|
||||
''.toString();
|
||||
''.endsWith('');
|
||||
}
|
||||
}
|
||||
|
||||
main() {
|
||||
CoreRuntimeTypesTest.testMain();
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
# Copyright (c) 2017, 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.
|
||||
|
||||
bigint_parse_radix_test/3: Slow # Issue http://dartbug.com/47050
|
||||
bigint_test: Pass, Slow
|
||||
|
||||
[ $builder_tag == obfuscated ]
|
||||
apply_generic_function_test: SkipByDesign # Function.apply with named args
|
||||
apply_test: Skip # Uses new Symbol via symbolMapToStringMap helper
|
||||
dynamic_nosuchmethod_test: SkipByDesign # Expects names in NSM
|
||||
nsm_invocation_test: SkipByDesign # Relies on non-obfuscated symbols
|
||||
symbol_test: SkipByDesign # Relies on non-obfuscated symbols
|
||||
type_tostring_test: SkipByDesign # Expects names in Type.toString()
|
||||
|
||||
[ $compiler == dartkp ]
|
||||
bigint_parse_radix_test: Slow, Pass # --no_intrinsify
|
||||
bigint_test/03: SkipSlow # --no_intrinsify
|
||||
bigint_test/15: SkipSlow # --no_intrinsify
|
||||
|
||||
[ $compiler == ddc ]
|
||||
bigint_test/03: SkipSlow # modPow is very slow
|
||||
bigint_test/15: SkipSlow # modPow is very slow
|
||||
list_concurrent_modify_self_test: SkipSlow # missing check causes list to grow to whole heap
|
||||
regexp/lookbehind_test/01: Skip # Flaky in uncatchable way. Issue 36280
|
||||
uri_parse_test: Slow, Pass
|
||||
uri_test: Slow, Pass
|
||||
|
||||
[ $mode == debug ]
|
||||
regexp/pcre_test: Slow, Pass # Issue 22008
|
||||
|
||||
[ $runtime != none ]
|
||||
string_runes_test: Skip # See breaking change #40674
|
||||
|
||||
[ $system == android ]
|
||||
throw_half_surrogate_pair_test/*: Skip # Issue http://dartbug.com/42094
|
||||
|
||||
[ $simulator ]
|
||||
bigint_parse_radix_test: Skip # Issue 31659
|
||||
bigint_test: Skip # Issue 31659
|
||||
|
||||
[ $arch == x64 && $system == windows ]
|
||||
stopwatch_test: Skip # Flaky test due to expected performance behaviour.
|
||||
|
||||
[ $compiler != dart2analyzer && $compiler != dart2js && $compiler != ddc ]
|
||||
bigint_js_test: SkipByDesign # JavaScript-specific test
|
||||
|
||||
[ $compiler == dart2js && $runtime != none ]
|
||||
regexp/pcre_test: Slow, Pass # Issue 21593
|
||||
|
||||
[ $compiler == dart2js && $runtime == safari ]
|
||||
date_time11_test: Skip # evades flake detection https://github.com/dart-lang/sdk/issues/50718
|
||||
local_date_time_test: Skip # evades flake detection https://github.com/dart-lang/sdk/issues/50718
|
||||
regexp/unicode-property-char-class_test: Skip # evades flake detection https://github.com/dart-lang/sdk/issues/50718
|
||||
regexp/unicode-property-invalid_test: Skip # evades flake detection https://github.com/dart-lang/sdk/issues/50718
|
||||
regexp/unicode-regexp-restricted-syntax_test: Skip # evades flake detection https://github.com/dart-lang/sdk/issues/50718
|
||||
|
||||
[ $runtime != dart_precompiled && $runtime != vm ]
|
||||
reg_exp_receive_port_test: SkipByDesign # uses SendPort/ReceivePort
|
||||
|
||||
[ $runtime != none && ($compiler == dart2js || $compiler == ddc) ]
|
||||
int_parse_with_limited_ints_test: SkipByDesign # Requires fixed-size int64 support.
|
||||
integer_arith_vm_test: SkipByDesign # Is a VM optimization test that requires int64 support.
|
||||
iterable_return_type_int64_test: SkipByDesign # Requires int64 support.
|
||||
typed_data_with_limited_ints_test: SkipByDesign # Requires fixed-size int64 support.
|
||||
|
||||
[ $builder_tag == dwarf || $builder_tag == obfuscated ]
|
||||
error_stack_trace1_test: SkipByDesign # Relies on symbol names in stack traces.
|
||||
|
||||
[ $runtime == dart_precompiled || $runtime == vm ]
|
||||
regexp/global_test: Skip # Issue 21709
|
||||
regexp/pcre_test: Slow, Pass
|
||||
|
||||
[ $hot_reload || $hot_reload_rollback ]
|
||||
bigint_parse_radix_test: Skip # Issue 31659. Issue 34361.
|
||||
bigint_test: Skip # Issue 31659
|
||||
integer_parsed_mul_div_vm_test: Slow, Pass # Slow
|
|
@ -1,344 +0,0 @@
|
|||
// Copyright (c) 2015, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
import "dart:convert";
|
||||
import "dart:typed_data";
|
||||
|
||||
main() {
|
||||
testMediaType();
|
||||
|
||||
testRoundTrip("");
|
||||
testRoundTrip("a");
|
||||
testRoundTrip("ab");
|
||||
testRoundTrip("abc");
|
||||
testRoundTrip("abcd");
|
||||
testRoundTrip("Content with special%25 characters: # ? = % # ? = %");
|
||||
testRoundTrip("blåbærgrød", utf8);
|
||||
testRoundTrip("blåbærgrød", latin1);
|
||||
|
||||
testUriEquals("data:,abc?d");
|
||||
testUriEquals("DATA:,ABC?D");
|
||||
testUriEquals("data:,a%20bc?d");
|
||||
testUriEquals("DATA:,A%20BC?D");
|
||||
testUriEquals("data:,abc?d%23e"); // # must and will be is escaped.
|
||||
|
||||
// Test that UriData.uri normalizes path and query.
|
||||
|
||||
testUtf8Encoding("\u1000\uffff");
|
||||
testBytes();
|
||||
testInvalidCharacters();
|
||||
testNormalization();
|
||||
testErrors();
|
||||
}
|
||||
|
||||
void testMediaType() {
|
||||
for (var mimeType in ["", "text/plain", "Text/PLAIN", "text/javascript"]) {
|
||||
for (var charset in ["", "US-ASCII", "UTF-8"]) {
|
||||
for (var base64 in ["", ";base64"]) {
|
||||
bool isBase64 = base64.isNotEmpty;
|
||||
// Parsing the URI from source:
|
||||
var charsetParameter = charset.isEmpty ? "" : ";charset=$charset";
|
||||
var text = "data:$mimeType$charsetParameter$base64,";
|
||||
var uri = UriData.parse(text);
|
||||
|
||||
String expectedCharset = charset.isEmpty ? "US-ASCII" : charset;
|
||||
String expectedMimeType = mimeType.isEmpty ? "text/plain" : mimeType;
|
||||
|
||||
Expect.equals(text, "$uri");
|
||||
Expect.equals(expectedMimeType, uri.mimeType);
|
||||
Expect.isTrue(uri.isMimeType(expectedMimeType));
|
||||
Expect.isTrue(uri.isMimeType(expectedMimeType.toUpperCase()));
|
||||
Expect.isTrue(uri.isMimeType(expectedMimeType.toLowerCase()));
|
||||
Expect.equals(expectedCharset, uri.charset);
|
||||
Expect.isTrue(uri.isCharset(expectedCharset));
|
||||
Expect.isTrue(uri.isCharset(expectedCharset.toLowerCase()));
|
||||
Expect.isTrue(uri.isCharset(expectedCharset.toUpperCase()));
|
||||
var expectedEncoding = Encoding.getByName(expectedCharset);
|
||||
if (expectedEncoding != null) {
|
||||
Expect.isTrue(uri.isEncoding(expectedEncoding));
|
||||
}
|
||||
Expect.equals(isBase64, uri.isBase64);
|
||||
|
||||
// Creating the URI using a constructor:
|
||||
var encoding = Encoding.getByName(charset);
|
||||
uri = UriData.fromString("",
|
||||
mimeType: mimeType, encoding: encoding, base64: isBase64);
|
||||
expectedMimeType =
|
||||
(mimeType.isEmpty || mimeType.toLowerCase() == "text/plain")
|
||||
? "text/plain"
|
||||
: mimeType;
|
||||
expectedEncoding = encoding;
|
||||
expectedCharset = expectedEncoding?.name ?? "US-ASCII";
|
||||
var expectedText = "data:"
|
||||
"${expectedMimeType == "text/plain" ? "" : expectedMimeType}"
|
||||
"${charset.isEmpty ? "" : ";charset=$expectedCharset"}"
|
||||
"${isBase64 ? ";base64" : ""}"
|
||||
",";
|
||||
|
||||
Expect.equals(expectedText, "$uri");
|
||||
Expect.equals(expectedMimeType, uri.mimeType);
|
||||
Expect.isTrue(uri.isMimeType(expectedMimeType));
|
||||
Expect.isTrue(uri.isMimeType(expectedMimeType.toUpperCase()));
|
||||
Expect.isTrue(uri.isMimeType(expectedMimeType.toLowerCase()));
|
||||
Expect.equals(expectedCharset, uri.charset);
|
||||
Expect.isTrue(uri.isCharset(expectedCharset));
|
||||
Expect.isTrue(uri.isCharset(expectedCharset.toLowerCase()));
|
||||
Expect.isTrue(uri.isCharset(expectedCharset.toUpperCase()));
|
||||
if (expectedEncoding != null) {
|
||||
Expect.isTrue(uri.isEncoding(expectedEncoding));
|
||||
}
|
||||
Expect.equals(isBase64, uri.isBase64);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void testRoundTrip(String content, [Encoding encoding]) {
|
||||
UriData dataUri = new UriData.fromString(content, encoding: encoding);
|
||||
Expect.isFalse(dataUri.isBase64);
|
||||
Uri uri = dataUri.uri;
|
||||
expectUriEquals(new Uri.dataFromString(content, encoding: encoding), uri);
|
||||
|
||||
if (encoding != null) {
|
||||
UriData dataUriParams =
|
||||
new UriData.fromString(content, parameters: {"charset": encoding.name});
|
||||
Expect.equals("$dataUri", "$dataUriParams");
|
||||
}
|
||||
|
||||
Expect.equals(encoding ?? ascii, Encoding.getByName(dataUri.charset));
|
||||
Expect.equals(content, dataUri.contentAsString(encoding: encoding));
|
||||
Expect.equals(content, dataUri.contentAsString());
|
||||
Expect.equals(content, (encoding ?? ascii).decode(dataUri.contentAsBytes()));
|
||||
|
||||
uri = dataUri.uri;
|
||||
Expect.equals(uri.toString(), dataUri.toString());
|
||||
Expect.equals(dataUri.toString(), new UriData.fromUri(uri).toString());
|
||||
|
||||
dataUri = new UriData.fromBytes(content.codeUnits);
|
||||
Expect.listEquals(content.codeUnits, dataUri.contentAsBytes());
|
||||
Expect.equals(content, dataUri.contentAsString(encoding: latin1));
|
||||
|
||||
uri = dataUri.uri;
|
||||
Expect.equals(uri.toString(), dataUri.toString());
|
||||
Expect.equals(dataUri.toString(), new UriData.fromUri(uri).toString());
|
||||
// Check that the URI is properly normalized.
|
||||
expectUriEquals(uri, Uri.parse("$uri"));
|
||||
}
|
||||
|
||||
void testUtf8Encoding(String content) {
|
||||
UriData uri = new UriData.fromString(content, encoding: utf8);
|
||||
Expect.equals(content, uri.contentAsString(encoding: utf8));
|
||||
Expect.listEquals(utf8.encode(content), uri.contentAsBytes());
|
||||
}
|
||||
|
||||
void testInvalidCharacters() {
|
||||
// SPACE, CTL and tspecial, plus '%' and '#' (URI gen-delim)
|
||||
// This contains all ASCII character that are not valid in attribute/value
|
||||
// parts.
|
||||
var invalid =
|
||||
'\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x7f'
|
||||
' ()<>@,;:"/[]?=%#\x80\u{1000}\u{10000}';
|
||||
var invalidNoSlash = invalid.replaceAll('/', '');
|
||||
var dataUri = new UriData.fromString(invalid,
|
||||
encoding: utf8,
|
||||
mimeType: "$invalidNoSlash/$invalidNoSlash",
|
||||
parameters: {invalid: invalid});
|
||||
|
||||
Expect.equals(invalid, dataUri.contentAsString());
|
||||
Expect.equals("$invalidNoSlash/$invalidNoSlash", dataUri.mimeType);
|
||||
Expect.equals(invalid, dataUri.parameters[invalid]);
|
||||
|
||||
var uri = dataUri.uri;
|
||||
Expect.equals("$uri", "$dataUri");
|
||||
expectUriEquals(uri, Uri.parse("$uri")); // Check that it's canonicalized.
|
||||
Expect.equals("$dataUri", new UriData.fromUri(uri).toString());
|
||||
}
|
||||
|
||||
void testBytes() {
|
||||
void testList(List<int> list) {
|
||||
var dataUri = new UriData.fromBytes(list);
|
||||
Expect.equals("application/octet-stream", dataUri.mimeType);
|
||||
Expect.isTrue(dataUri.isBase64);
|
||||
Expect.listEquals(list, dataUri.contentAsBytes());
|
||||
|
||||
dataUri = new UriData.fromBytes(list, percentEncoded: true);
|
||||
Expect.equals("application/octet-stream", dataUri.mimeType);
|
||||
Expect.isFalse(dataUri.isBase64);
|
||||
Expect.listEquals(list, dataUri.contentAsBytes());
|
||||
|
||||
var string = new String.fromCharCodes(list);
|
||||
|
||||
dataUri = new UriData.fromString(string, encoding: latin1);
|
||||
Expect.equals("text/plain", dataUri.mimeType);
|
||||
Expect.isFalse(dataUri.isBase64);
|
||||
Expect.listEquals(list, dataUri.contentAsBytes());
|
||||
|
||||
dataUri = new UriData.fromString(string, encoding: latin1, base64: true);
|
||||
Expect.equals("text/plain", dataUri.mimeType);
|
||||
Expect.isTrue(dataUri.isBase64);
|
||||
Expect.listEquals(list, dataUri.contentAsBytes());
|
||||
}
|
||||
|
||||
void testLists(List<int> list) {
|
||||
testList(list);
|
||||
for (int i = 0; i < 27; i++) {
|
||||
testList(list.sublist(i, i + i)); // All lengths from 0 to 27.
|
||||
}
|
||||
}
|
||||
|
||||
var bytes = new Uint8List(512);
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
bytes[i] = i;
|
||||
}
|
||||
testLists(bytes);
|
||||
testLists(new List.from(bytes));
|
||||
testLists(new List.unmodifiable(bytes));
|
||||
}
|
||||
|
||||
void testNormalization() {
|
||||
// Base-64 normalization.
|
||||
|
||||
// Normalized URI-alphabet characters.
|
||||
Expect.equals(
|
||||
"data:;base64,AA/+", UriData.parse("data:;base64,AA_-").toString());
|
||||
// Normalized escapes.
|
||||
Expect.equals(
|
||||
"data:;base64,AB==", UriData.parse("data:;base64,A%42=%3D").toString());
|
||||
Expect.equals("data:;base64,/+/+",
|
||||
UriData.parse("data:;base64,%5F%2D%2F%2B").toString());
|
||||
// Normalized padded data.
|
||||
Expect.equals(
|
||||
"data:;base64,AA==", UriData.parse("data:;base64,AA%3D%3D").toString());
|
||||
Expect.equals(
|
||||
"data:;base64,AAA=", UriData.parse("data:;base64,AAA%3D").toString());
|
||||
// Normalized unpadded data.
|
||||
Expect.equals(
|
||||
"data:;base64,AA==", UriData.parse("data:;base64,AA").toString());
|
||||
Expect.equals(
|
||||
"data:;base64,AAA=", UriData.parse("data:;base64,AAA").toString());
|
||||
|
||||
// "URI normalization" of non-base64 content.
|
||||
var uri = UriData.parse("data:,\x20\xa0");
|
||||
Expect.equals("data:,%20%C2%A0", uri.toString());
|
||||
uri = UriData.parse("data:,x://x@y:[z]:42/p/./?q=x&y=z#?#\u1234\u{12345}");
|
||||
Expect.equals(
|
||||
"data:,x://x@y:%5Bz%5D:42/p/./?q=x&y=z%23?%23%E1%88%B4%F0%92%8D%85",
|
||||
uri.toString());
|
||||
}
|
||||
|
||||
void testErrors() {
|
||||
// Invalid constructor parameters.
|
||||
Expect.throwsArgumentError(
|
||||
() => new UriData.fromBytes([], mimeType: "noslash"));
|
||||
Expect.throwsArgumentError(() => new UriData.fromBytes([257]));
|
||||
Expect.throwsArgumentError(() => new UriData.fromBytes([-1]));
|
||||
Expect.throwsArgumentError(() => new UriData.fromBytes([0x10000000]));
|
||||
Expect.throwsArgumentError(
|
||||
() => new UriData.fromString("", mimeType: "noslash"));
|
||||
|
||||
Expect.throwsArgumentError(
|
||||
() => new Uri.dataFromBytes([], mimeType: "noslash"));
|
||||
Expect.throwsArgumentError(() => new Uri.dataFromBytes([257]));
|
||||
Expect.throwsArgumentError(() => new Uri.dataFromBytes([-1]));
|
||||
Expect.throwsArgumentError(() => new Uri.dataFromBytes([0x10000000]));
|
||||
Expect.throwsArgumentError(
|
||||
() => new Uri.dataFromString("", mimeType: "noslash"));
|
||||
|
||||
// Empty parameters allowed, not an error.
|
||||
var uri = new UriData.fromString("", mimeType: "", parameters: {});
|
||||
Expect.equals("data:,", "$uri");
|
||||
// Empty parameter key or value is an error.
|
||||
Expect.throwsArgumentError(
|
||||
() => new UriData.fromString("", parameters: {"": "X"}));
|
||||
Expect.throwsArgumentError(
|
||||
() => new UriData.fromString("", parameters: {"X": ""}));
|
||||
|
||||
// Not recognizing charset is an error.
|
||||
uri = UriData.parse("data:;charset=arglebargle,X");
|
||||
Expect.throws(() {
|
||||
uri.contentAsString();
|
||||
});
|
||||
// Doesn't throw if we specify the encoding.
|
||||
Expect.equals("X", uri.contentAsString(encoding: ascii));
|
||||
|
||||
// Parse format.
|
||||
Expect.throwsFormatException(() => UriData.parse("notdata:,"));
|
||||
Expect.throwsFormatException(() => UriData.parse("text/plain,noscheme"));
|
||||
Expect.throwsFormatException(() => UriData.parse("data:noseparator"));
|
||||
Expect.throwsFormatException(() => UriData.parse("data:noslash,text"));
|
||||
Expect.throwsFormatException(
|
||||
() => UriData.parse("data:type/sub;noequals,text"));
|
||||
Expect.throwsFormatException(() => UriData.parse("data:type/sub;knocomma="));
|
||||
Expect.throwsFormatException(
|
||||
() => UriData.parse("data:type/sub;k=v;nocomma"));
|
||||
Expect.throwsFormatException(() => UriData.parse("data:type/sub;k=nocomma"));
|
||||
Expect.throwsFormatException(() => UriData.parse("data:type/sub;k=v;base64"));
|
||||
|
||||
void formatError(String input) {
|
||||
Expect.throwsFormatException(
|
||||
() => UriData.parse("data:;base64,$input"), input);
|
||||
}
|
||||
|
||||
// Invalid base64 format (detected when parsed).
|
||||
for (var a = 0; a <= 4; a++) {
|
||||
for (var p = 0; p <= 4; p++) {
|
||||
// Base-64 encoding must have length divisible by four and no more
|
||||
// than two padding characters at the end.
|
||||
if (p < 3 && (a + p) % 4 == 0) continue;
|
||||
if (p == 0 && a > 1) continue;
|
||||
formatError("A" * a + "=" * p);
|
||||
formatError("A" * a + "%3D" * p);
|
||||
}
|
||||
}
|
||||
// Invalid base64 encoding: padding not at end.
|
||||
formatError("AA=A");
|
||||
formatError("A=AA");
|
||||
formatError("=AAA");
|
||||
formatError("A==A");
|
||||
formatError("==AA");
|
||||
formatError("===A");
|
||||
formatError("AAA%3D=");
|
||||
formatError("A%3D==");
|
||||
|
||||
// Invalid unpadded data.
|
||||
formatError("A");
|
||||
formatError("AAAAA");
|
||||
|
||||
// Invalid characters.
|
||||
formatError("AAA*");
|
||||
formatError("AAA\x00");
|
||||
formatError("AAA\\");
|
||||
formatError("AAA,");
|
||||
|
||||
// Invalid escapes.
|
||||
formatError("AAA%25");
|
||||
formatError("AAA%7F");
|
||||
formatError("AAA%7F");
|
||||
}
|
||||
|
||||
/// Checks that two [Uri]s are exactly the same.
|
||||
expectUriEquals(Uri expect, Uri actual) {
|
||||
Expect.equals(expect.scheme, actual.scheme, "scheme");
|
||||
Expect.equals(expect.hasAuthority, actual.hasAuthority, "hasAuthority");
|
||||
Expect.equals(expect.userInfo, actual.userInfo, "userInfo");
|
||||
Expect.equals(expect.host, actual.host, "host");
|
||||
Expect.equals(expect.hasPort, actual.hasPort, "hasPort");
|
||||
Expect.equals(expect.port, actual.port, "port");
|
||||
Expect.equals(expect.port, actual.port, "port");
|
||||
Expect.equals(expect.hasQuery, actual.hasQuery, "hasQuery");
|
||||
Expect.equals(expect.query, actual.query, "query");
|
||||
Expect.equals(expect.hasFragment, actual.hasFragment, "hasFragment");
|
||||
Expect.equals(expect.fragment, actual.fragment, "fragment");
|
||||
}
|
||||
|
||||
void testUriEquals(String uriText) {
|
||||
var data = UriData.parse(uriText);
|
||||
var uri = Uri.parse(uriText);
|
||||
Expect.equals(data.uri, uri);
|
||||
Expect.equals(data.toString(), uri.data.toString());
|
||||
Expect.equals(data.toString(), uri.toString());
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
// Copyright (c) 2012, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
// Make sure the years in the range of single digits are handled correctly with
|
||||
// month roll-over. (This tests an edge condition when delegating to
|
||||
// JavaScript's Date constructor.)
|
||||
|
||||
void check(String expected, DateTime actual) {
|
||||
Expect.equals(expected, actual.toString());
|
||||
}
|
||||
|
||||
testUtc() {
|
||||
check("0099-01-01 00:00:00.000Z", new DateTime.utc(99, 1));
|
||||
check("0100-01-01 00:00:00.000Z", new DateTime.utc(99, 1 + 12));
|
||||
check("0000-01-01 00:00:00.000Z", new DateTime.utc(0, 1));
|
||||
check("-0001-01-01 00:00:00.000Z", new DateTime.utc(0, 1 - 12));
|
||||
|
||||
check("0099-03-02 00:00:00.000Z", new DateTime.utc(99, 2, 30));
|
||||
check("0100-03-02 00:00:00.000Z", new DateTime.utc(99, 2 + 12, 30));
|
||||
|
||||
check("0004-03-01 00:00:00.000Z", new DateTime.utc(3, 2 + 12, 30));
|
||||
check("0004-03-01 00:00:00.000Z", new DateTime.utc(4, 2, 30));
|
||||
check("0004-03-01 00:00:00.000Z", new DateTime.utc(5, 2 - 12, 30));
|
||||
|
||||
check("0005-03-02 00:00:00.000Z", new DateTime.utc(4, 2 + 12, 30));
|
||||
check("0005-03-02 00:00:00.000Z", new DateTime.utc(5, 2, 30));
|
||||
check("0005-03-02 00:00:00.000Z", new DateTime.utc(6, 2 - 12, 30));
|
||||
}
|
||||
|
||||
testLocal() {
|
||||
check("0099-01-01 00:00:00.000", new DateTime(99, 1));
|
||||
check("0100-01-01 00:00:00.000", new DateTime(99, 1 + 12));
|
||||
check("0000-01-01 00:00:00.000", new DateTime(0, 1));
|
||||
check("-0001-01-01 00:00:00.000", new DateTime(0, 1 - 12));
|
||||
|
||||
check("0099-03-02 00:00:00.000", new DateTime(99, 2, 30));
|
||||
check("0100-03-02 00:00:00.000", new DateTime(99, 2 + 12, 30));
|
||||
|
||||
check("0004-03-01 00:00:00.000", new DateTime(3, 2 + 12, 30));
|
||||
check("0004-03-01 00:00:00.000", new DateTime(4, 2, 30));
|
||||
check("0004-03-01 00:00:00.000", new DateTime(5, 2 - 12, 30));
|
||||
|
||||
check("0005-03-02 00:00:00.000", new DateTime(4, 2 + 12, 30));
|
||||
check("0005-03-02 00:00:00.000", new DateTime(5, 2, 30));
|
||||
check("0005-03-02 00:00:00.000", new DateTime(6, 2 - 12, 30));
|
||||
}
|
||||
|
||||
main() {
|
||||
testUtc();
|
||||
testLocal();
|
||||
}
|
|
@ -1,140 +0,0 @@
|
|||
// Copyright (c) 2017, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
// Make sure that date-times close to daylight savings work correctly.
|
||||
// See http://dartbug.com/30550
|
||||
|
||||
/// A list of (decomposed) date-times where daylight saving changes
|
||||
/// happen.
|
||||
///
|
||||
/// This list covers multiple timezones to increase test coverage on
|
||||
/// different machines.
|
||||
final daylightSavingChanges = [
|
||||
// TZ environment, y, m, d, h, change.
|
||||
["Europe/Paris", 2017, 03, 26, 02, 60],
|
||||
["Europe/Paris", 2017, 10, 29, 03, -60],
|
||||
["Antarctica/Troll", 2017, 03, 19, 01, 120],
|
||||
["Antarctica/Troll", 2017, 10, 29, 03, -120],
|
||||
["Australia/Canberra", 2017, 04, 02, 03, -60],
|
||||
["Australia/Canberra", 2017, 10, 01, 02, 60],
|
||||
["Australia/Lord_Howe", 2017, 04, 02, 02, -30],
|
||||
["Australia/Lord_Howe", 2017, 10, 01, 02, 30],
|
||||
["Atlantic/Bermuda", 2017, 03, 12, 02, 60], // US and Canada.
|
||||
["Atlantic/Bermuda", 2017, 11, 05, 02, -60],
|
||||
["America/Campo_Grande", 2017, 02, 19, 00, -60], // Brazil
|
||||
["America/Campo_Grande", 2017, 10, 15, 00, 60],
|
||||
["America/Santiago", 2017, 05, 14, 00, -60],
|
||||
["America/Santiago", 2017, 08, 13, 00, 60],
|
||||
["Chile/EasterIsland", 2017, 05, 13, 22, -60],
|
||||
["Chile/EasterIsland", 2017, 08, 12, 22, 60],
|
||||
["Pacific/Fiji", 2017, 01, 15, 03, -60],
|
||||
["Pacific/Fiji", 2017, 11, 05, 02, 60],
|
||||
["America/Scoresbysund", 2017, 03, 26, 00, 60], // Ittoqqortoormiit.
|
||||
["America/Scoresbysund", 2017, 10, 29, 01, -60],
|
||||
["Asia/Tehran", 2017, 03, 22, 00, 60],
|
||||
["Asia/Tehran", 2017, 09, 22, 00, -60],
|
||||
["Israel", 2017, 03, 24, 02, 60],
|
||||
["Israel", 2017, 10, 29, 02, -60],
|
||||
["Asia/Amman", 2017, 03, 31, 00, 60],
|
||||
["Asia/Amman", 2017, 10, 27, 01, -60],
|
||||
["Mexico/General", 2017, 04, 02, 02, 60],
|
||||
["Mexico/General", 2017, 10, 29, 02, -60],
|
||||
];
|
||||
|
||||
void runTests() {
|
||||
// Makes sure we don't go into the wrong direction during a
|
||||
// daylight-savings change (as happened in #30550).
|
||||
for (var test in daylightSavingChanges) {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
int year = test[1];
|
||||
int month = test[2];
|
||||
int day = test[3];
|
||||
int hour = test[4];
|
||||
|
||||
int minute = i == 0 ? 0 : test[5];
|
||||
// Rather adjust the hours than keeping the minutes.
|
||||
hour += minute ~/ 60;
|
||||
minute = minute.remainder(60);
|
||||
if (hour < 0) {
|
||||
hour += 24;
|
||||
day--;
|
||||
}
|
||||
|
||||
{
|
||||
// Check that microseconds are taken into account.
|
||||
var dtMillisecond = new DateTime(year, month, day, hour, minute, 0, 1);
|
||||
var dtSecond = new DateTime(year, month, day, hour, minute, 1);
|
||||
Expect.equals(const Duration(milliseconds: 999),
|
||||
dtSecond.difference(dtMillisecond));
|
||||
|
||||
dtMillisecond = new DateTime(year, month, day, hour, minute, 0, -1);
|
||||
dtSecond = new DateTime(year, month, day, hour, minute, -1);
|
||||
Expect.equals(const Duration(milliseconds: 999),
|
||||
dtMillisecond.difference(dtSecond));
|
||||
}
|
||||
|
||||
var dt1 = new DateTime(year, month, day, hour);
|
||||
var dt2 = new DateTime(year, month, day, hour, 1);
|
||||
|
||||
// Earlier:
|
||||
int earlierDay = day;
|
||||
int earlierHour = hour - 1;
|
||||
if (earlierHour < 0) {
|
||||
earlierHour = 23;
|
||||
earlierDay--;
|
||||
}
|
||||
var dt3 = new DateTime(year, month, earlierDay, earlierHour, 59);
|
||||
|
||||
var diff1 = dt2.difference(dt1).inMinutes;
|
||||
var diff2 = dt1.difference(dt3).inMinutes;
|
||||
|
||||
if (diff1 == 1 && diff2 == 1 && dt1.hour == hour && dt1.minute == 0) {
|
||||
// Regular date-time.
|
||||
continue;
|
||||
}
|
||||
|
||||
// At most one is at a distance of more than a minute.
|
||||
Expect.isTrue(diff1 == 1 || diff2 == 1);
|
||||
|
||||
if (diff2 < 0) {
|
||||
// This happens, when we ask for invalid times.
|
||||
// Suppose daylight-saving is at 2:00 and switches to 3:00. If we
|
||||
// ask for 2:59, we get 3:59 (59 minutes after 2:00).
|
||||
Expect.isFalse(dt3.day == earlierDay && dt3.hour == earlierHour);
|
||||
// If that's the case, then removing one minute from dt1 should
|
||||
// not yield a date-time with the earlier values, and it should
|
||||
// be far away from dt3.
|
||||
var dt4 = dt1.add(const Duration(minutes: -1));
|
||||
Expect.isFalse(dt4.day == earlierDay && dt4.hour == earlierHour);
|
||||
Expect.isTrue(dt4.isBefore(dt1));
|
||||
Expect.isTrue(dt4.day < earlierDay ||
|
||||
(dt4.day == earlierDay && dt4.hour < earlierHour));
|
||||
continue;
|
||||
}
|
||||
|
||||
// They must be in the right order.
|
||||
Expect.isTrue(dt1.isBefore(dt2));
|
||||
Expect.isTrue(dt3.isBefore(dt1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void main(List<String> args) {
|
||||
// The following code constructs a String with all timezones that are
|
||||
// relevant for this test.
|
||||
// This can be helpful for running tests in multiple timezones.
|
||||
// Typically, one would write something like:
|
||||
// for tz in <contents_of_string>; do TZ=$tz tools/test.py ...; done
|
||||
var result = new StringBuffer();
|
||||
for (int i = 0; i < daylightSavingChanges.length; i += 2) {
|
||||
if (i != 0) result.write(" ");
|
||||
result.write(daylightSavingChanges[i][0]);
|
||||
}
|
||||
|
||||
runTests();
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
// Copyright (c) 2012, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
// Dart test program for DateTime's hashCode.
|
||||
|
||||
main() {
|
||||
var d = DateTime.parse("2000-01-01T00:00:00Z");
|
||||
var d2 = DateTime.parse("2000-01-01T00:00:01Z");
|
||||
// There is no guarantee that the hashcode for these two dates is different,
|
||||
// but in the worst case we will have to fix this test.
|
||||
// The important test here is, that DateTime .
|
||||
Expect.isFalse(d.hashCode == d2.hashCode);
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
// Copyright (c) 2012, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
// At some point dart was emitting a bad padding 0 for Dates where the ms were
|
||||
// ending with 10.
|
||||
|
||||
main() {
|
||||
String s = "2012-01-30 08:30:00.010";
|
||||
DateTime d = DateTime.parse(s);
|
||||
Expect.equals(s, d.toString());
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
// Copyright (c) 2012, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
// Test fromString with 6 digits after the decimal point.
|
||||
|
||||
bool get supportsMicroseconds =>
|
||||
new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1;
|
||||
|
||||
main() {
|
||||
if (supportsMicroseconds) {
|
||||
testMicrosecondPrecision();
|
||||
} else {
|
||||
testMillisecondPrecision();
|
||||
}
|
||||
}
|
||||
|
||||
void testMillisecondPrecision() {
|
||||
// We only support milliseconds. If the user supplies more data (the "51"
|
||||
// here), we round.
|
||||
DateTime dt1 = DateTime.parse("1999-01-02 23:59:59.999519");
|
||||
Expect.equals(1999, dt1.year);
|
||||
Expect.equals(1, dt1.month);
|
||||
Expect.equals(3, dt1.day);
|
||||
Expect.equals(0, dt1.hour);
|
||||
Expect.equals(0, dt1.minute);
|
||||
Expect.equals(0, dt1.second);
|
||||
Expect.equals(0, dt1.millisecond);
|
||||
Expect.equals(false, dt1.isUtc);
|
||||
dt1 = DateTime.parse("1999-01-02 23:58:59.999519Z");
|
||||
Expect.equals(1999, dt1.year);
|
||||
Expect.equals(1, dt1.month);
|
||||
Expect.equals(2, dt1.day);
|
||||
Expect.equals(23, dt1.hour);
|
||||
Expect.equals(59, dt1.minute);
|
||||
Expect.equals(0, dt1.second);
|
||||
Expect.equals(0, dt1.millisecond);
|
||||
Expect.equals(true, dt1.isUtc);
|
||||
dt1 = DateTime.parse("0009-09-09 09:09:09.009411Z");
|
||||
Expect.equals(9, dt1.year);
|
||||
Expect.equals(9, dt1.month);
|
||||
Expect.equals(9, dt1.day);
|
||||
Expect.equals(9, dt1.hour);
|
||||
Expect.equals(9, dt1.minute);
|
||||
Expect.equals(9, dt1.second);
|
||||
Expect.equals(9, dt1.millisecond);
|
||||
Expect.equals(true, dt1.isUtc);
|
||||
String svnDate = "2012-03-30T04:28:13.752341Z";
|
||||
dt1 = DateTime.parse(svnDate);
|
||||
Expect.equals(2012, dt1.year);
|
||||
Expect.equals(3, dt1.month);
|
||||
Expect.equals(30, dt1.day);
|
||||
Expect.equals(4, dt1.hour);
|
||||
Expect.equals(28, dt1.minute);
|
||||
Expect.equals(13, dt1.second);
|
||||
Expect.equals(752, dt1.millisecond);
|
||||
Expect.equals(true, dt1.isUtc);
|
||||
}
|
||||
|
||||
void testMicrosecondPrecision() {
|
||||
DateTime dt1 = DateTime.parse("1999-01-02 23:59:59.999519");
|
||||
Expect.equals(1999, dt1.year);
|
||||
Expect.equals(1, dt1.month);
|
||||
Expect.equals(2, dt1.day);
|
||||
Expect.equals(23, dt1.hour);
|
||||
Expect.equals(59, dt1.minute);
|
||||
Expect.equals(59, dt1.second);
|
||||
Expect.equals(999, dt1.millisecond);
|
||||
Expect.equals(519, dt1.microsecond);
|
||||
Expect.equals(false, dt1.isUtc);
|
||||
dt1 = DateTime.parse("1999-01-02 23:58:59.999519Z");
|
||||
Expect.equals(1999, dt1.year);
|
||||
Expect.equals(1, dt1.month);
|
||||
Expect.equals(2, dt1.day);
|
||||
Expect.equals(23, dt1.hour);
|
||||
Expect.equals(58, dt1.minute);
|
||||
Expect.equals(59, dt1.second);
|
||||
Expect.equals(999, dt1.millisecond);
|
||||
Expect.equals(519, dt1.microsecond);
|
||||
Expect.equals(true, dt1.isUtc);
|
||||
dt1 = DateTime.parse("0009-09-09 09:09:09.009411Z");
|
||||
Expect.equals(9, dt1.year);
|
||||
Expect.equals(9, dt1.month);
|
||||
Expect.equals(9, dt1.day);
|
||||
Expect.equals(9, dt1.hour);
|
||||
Expect.equals(9, dt1.minute);
|
||||
Expect.equals(9, dt1.second);
|
||||
Expect.equals(9, dt1.millisecond);
|
||||
Expect.equals(411, dt1.microsecond);
|
||||
Expect.equals(true, dt1.isUtc);
|
||||
String svnDate = "2012-03-30T04:28:13.752341Z";
|
||||
dt1 = DateTime.parse(svnDate);
|
||||
Expect.equals(2012, dt1.year);
|
||||
Expect.equals(3, dt1.month);
|
||||
Expect.equals(30, dt1.day);
|
||||
Expect.equals(4, dt1.hour);
|
||||
Expect.equals(28, dt1.minute);
|
||||
Expect.equals(13, dt1.second);
|
||||
Expect.equals(752, dt1.millisecond);
|
||||
Expect.equals(341, dt1.microsecond);
|
||||
Expect.equals(true, dt1.isUtc);
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
// Copyright (c) 2012, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
// Test DateTime constructor with optional arguments.
|
||||
|
||||
main() {
|
||||
var d = new DateTime(2012);
|
||||
Expect.equals(2012, d.year);
|
||||
Expect.equals(1, d.month);
|
||||
Expect.equals(1, d.day);
|
||||
Expect.equals(0, d.hour);
|
||||
Expect.equals(0, d.minute);
|
||||
Expect.equals(0, d.second);
|
||||
Expect.equals(0, d.millisecond);
|
||||
|
||||
d = new DateTime(2012, 1, 28);
|
||||
Expect.equals(2012, d.year);
|
||||
Expect.equals(1, d.month);
|
||||
Expect.equals(28, d.day);
|
||||
Expect.equals(0, d.hour);
|
||||
Expect.equals(0, d.minute);
|
||||
Expect.equals(0, d.second);
|
||||
Expect.equals(0, d.millisecond);
|
||||
|
||||
d = new DateTime(1970, 3);
|
||||
Expect.equals(1970, d.year);
|
||||
Expect.equals(3, d.month);
|
||||
Expect.equals(1, d.day);
|
||||
Expect.equals(0, d.hour);
|
||||
Expect.equals(0, d.minute);
|
||||
Expect.equals(0, d.second);
|
||||
Expect.equals(0, d.millisecond);
|
||||
|
||||
d = new DateTime(1970, 3, 1, 11);
|
||||
Expect.equals(1970, d.year);
|
||||
Expect.equals(3, d.month);
|
||||
Expect.equals(1, d.day);
|
||||
Expect.equals(11, d.hour);
|
||||
Expect.equals(0, d.minute);
|
||||
Expect.equals(0, d.second);
|
||||
Expect.equals(0, d.millisecond);
|
||||
|
||||
d = new DateTime(0, 12, 24, 0, 12);
|
||||
Expect.equals(0, d.year);
|
||||
Expect.equals(12, d.month);
|
||||
Expect.equals(24, d.day);
|
||||
Expect.equals(0, d.hour);
|
||||
Expect.equals(12, d.minute);
|
||||
Expect.equals(0, d.second);
|
||||
Expect.equals(0, d.millisecond);
|
||||
|
||||
d = new DateTime(-1, 2, 2, 3, 0, 0, 4);
|
||||
Expect.equals(-1, d.year);
|
||||
Expect.equals(2, d.month);
|
||||
Expect.equals(2, d.day);
|
||||
Expect.equals(3, d.hour);
|
||||
Expect.equals(0, d.minute);
|
||||
Expect.equals(0, d.second);
|
||||
Expect.equals(4, d.millisecond);
|
||||
|
||||
d = new DateTime(-1, 2, 2, 3, 0, 4);
|
||||
Expect.equals(-1, d.year);
|
||||
Expect.equals(2, d.month);
|
||||
Expect.equals(2, d.day);
|
||||
Expect.equals(3, d.hour);
|
||||
Expect.equals(0, d.minute);
|
||||
Expect.equals(4, d.second);
|
||||
Expect.equals(0, d.millisecond);
|
||||
|
||||
d = new DateTime(2012, 5, 15, 13, 21, 33, 12);
|
||||
Expect.equals(2012, d.year);
|
||||
Expect.equals(5, d.month);
|
||||
Expect.equals(15, d.day);
|
||||
Expect.equals(13, d.hour);
|
||||
Expect.equals(21, d.minute);
|
||||
Expect.equals(33, d.second);
|
||||
Expect.equals(12, d.millisecond);
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
// Copyright (c) 2012, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
// Test DateTime comparison operators.
|
||||
|
||||
main() {
|
||||
var d = new DateTime.fromMillisecondsSinceEpoch(0, isUtc: true);
|
||||
var d2 = new DateTime.fromMillisecondsSinceEpoch(1, isUtc: true);
|
||||
Expect.isTrue(d.isBefore(d2));
|
||||
Expect.isTrue(!d.isAfter(d2));
|
||||
Expect.isTrue(d2.isAfter(d));
|
||||
Expect.isTrue(!d2.isBefore(d));
|
||||
Expect.isFalse(d2.isBefore(d));
|
||||
Expect.isFalse(!d2.isAfter(d));
|
||||
Expect.isFalse(d.isAfter(d2));
|
||||
Expect.isFalse(!d.isBefore(d2));
|
||||
|
||||
d = new DateTime.fromMillisecondsSinceEpoch(-1, isUtc: true);
|
||||
d2 = new DateTime.fromMillisecondsSinceEpoch(0, isUtc: true);
|
||||
Expect.isTrue(d.isBefore(d2));
|
||||
Expect.isTrue(!d.isAfter(d2));
|
||||
Expect.isTrue(d2.isAfter(d));
|
||||
Expect.isTrue(!d2.isBefore(d));
|
||||
Expect.isFalse(d2.isBefore(d));
|
||||
Expect.isFalse(!d2.isAfter(d));
|
||||
Expect.isFalse(d.isAfter(d2));
|
||||
Expect.isFalse(!d.isBefore(d2));
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
// Copyright (c) 2012, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
// Test DateTime timeZoneName and timeZoneOffset getters.
|
||||
|
||||
testUtc() {
|
||||
var d = DateTime.parse("2012-03-04T03:25:38.123Z");
|
||||
Expect.equals("UTC", d.timeZoneName);
|
||||
Expect.equals(0, d.timeZoneOffset.inSeconds);
|
||||
}
|
||||
|
||||
testLocal() {
|
||||
checkOffset(String name, Duration offset) {
|
||||
// Timezone abbreviations are not in bijection with their timezones.
|
||||
// For example AST stands for "Arab Standard Time" (UTC+03), as well as
|
||||
// "Arabian Standard Time" (UTC+04), or PST stands for Pacific Standard Time
|
||||
// and Philippine Standard Time.
|
||||
//
|
||||
// Hardcode some common timezones.
|
||||
if (name == "CET") {
|
||||
Expect.equals(1, offset.inHours);
|
||||
} else if (name == "CEST") {
|
||||
Expect.equals(2, offset.inHours);
|
||||
} else if (name == "GMT") {
|
||||
Expect.equals(0, offset.inSeconds);
|
||||
} else if (name == "EST") {
|
||||
Expect.equals(-5, offset.inHours);
|
||||
} else if (name == "EDT") {
|
||||
Expect.equals(-4, offset.inHours);
|
||||
} else if (name == "PDT") {
|
||||
Expect.equals(-7, offset.inHours);
|
||||
}
|
||||
}
|
||||
|
||||
var d = DateTime.parse("2012-01-02T13:45:23");
|
||||
String name = d.timeZoneName;
|
||||
checkOffset(name, d.timeZoneOffset);
|
||||
|
||||
d = DateTime.parse("2012-07-02T13:45:23");
|
||||
name = d.timeZoneName;
|
||||
checkOffset(name, d.timeZoneOffset);
|
||||
}
|
||||
|
||||
main() {
|
||||
testUtc();
|
||||
testLocal();
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
// Copyright (c) 2012, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
// Make sure the year 0 is correctly printed.
|
||||
|
||||
testUtc() {
|
||||
var d = new DateTime.utc(0, 1, 1);
|
||||
Expect.equals("0000-01-01 00:00:00.000Z", d.toString());
|
||||
}
|
||||
|
||||
testLocal() {
|
||||
var d = new DateTime(0, 1, 1);
|
||||
Expect.equals("0000-01-01 00:00:00.000", d.toString());
|
||||
}
|
||||
|
||||
main() {
|
||||
testUtc();
|
||||
testLocal();
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
main() {
|
||||
var dt = new DateTime.now();
|
||||
Expect.isTrue(dt is Comparable);
|
||||
|
||||
var dt2 = new DateTime.fromMillisecondsSinceEpoch(100);
|
||||
var dt3 = new DateTime.fromMillisecondsSinceEpoch(200, isUtc: true);
|
||||
var dt3b = new DateTime.fromMillisecondsSinceEpoch(200);
|
||||
var dt4 = new DateTime.fromMillisecondsSinceEpoch(300);
|
||||
var dt5 = new DateTime.fromMillisecondsSinceEpoch(400, isUtc: true);
|
||||
var dt5b = new DateTime.fromMillisecondsSinceEpoch(400);
|
||||
|
||||
Expect.isTrue(dt2.compareTo(dt2) == 0);
|
||||
Expect.isTrue(dt3.compareTo(dt3) == 0);
|
||||
Expect.isTrue(dt3b.compareTo(dt3b) == 0);
|
||||
Expect.isTrue(dt4.compareTo(dt4) == 0);
|
||||
Expect.isTrue(dt5.compareTo(dt5) == 0);
|
||||
Expect.isTrue(dt5b.compareTo(dt5b) == 0);
|
||||
|
||||
// Time zones don't have any effect.
|
||||
Expect.isTrue(dt3.compareTo(dt3b) == 0);
|
||||
Expect.isTrue(dt5.compareTo(dt5b) == 0);
|
||||
|
||||
Expect.isTrue(dt2.compareTo(dt3) < 0);
|
||||
Expect.isTrue(dt3.compareTo(dt4) < 0);
|
||||
Expect.isTrue(dt4.compareTo(dt5) < 0);
|
||||
|
||||
Expect.isTrue(dt2.compareTo(dt3b) < 0);
|
||||
Expect.isTrue(dt4.compareTo(dt5b) < 0);
|
||||
|
||||
Expect.isTrue(dt3.compareTo(dt2) > 0);
|
||||
Expect.isTrue(dt4.compareTo(dt3) > 0);
|
||||
Expect.isTrue(dt5.compareTo(dt4) > 0);
|
||||
|
||||
Expect.isTrue(dt3b.compareTo(dt2) > 0);
|
||||
Expect.isTrue(dt5b.compareTo(dt4) > 0);
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
// Copyright (c) 2012, 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.
|
||||
|
||||
// @dart=2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
// Dart test program for DateTime.copyWith.
|
||||
|
||||
testCopyWith(
|
||||
DateTime original,
|
||||
int year,
|
||||
int month,
|
||||
int day,
|
||||
int hour,
|
||||
int minute,
|
||||
int second,
|
||||
int millisecond,
|
||||
bool isUtc,
|
||||
) {
|
||||
final result = original.copyWith(
|
||||
year: year,
|
||||
month: month,
|
||||
day: day,
|
||||
hour: hour,
|
||||
minute: minute,
|
||||
second: second,
|
||||
millisecond: millisecond,
|
||||
isUtc: isUtc,
|
||||
);
|
||||
|
||||
final expected = isUtc
|
||||
? DateTime.utc(
|
||||
year != null ? year : original.year,
|
||||
month != null ? month : original.month,
|
||||
day != null ? day : original.day,
|
||||
hour != null ? hour : original.hour,
|
||||
minute != null ? minute : original.minute,
|
||||
second != null ? second : original.second,
|
||||
millisecond != null ? millisecond : original.millisecond,
|
||||
)
|
||||
: DateTime(
|
||||
year != null ? year : original.year,
|
||||
month != null ? month : original.month,
|
||||
day != null ? day : original.day,
|
||||
hour != null ? hour : original.hour,
|
||||
minute != null ? minute : original.minute,
|
||||
second != null ? second : original.second,
|
||||
millisecond != null ? millisecond : original.millisecond,
|
||||
);
|
||||
|
||||
Expect.equals(expected, result);
|
||||
}
|
||||
|
||||
void main() {
|
||||
final epoch = DateTime.utc(1970, 1, 1);
|
||||
final dst = DateTime.parse("2015-07-07T12:12:24Z");
|
||||
final leap = DateTime.parse("2012-02-28T12:12:24");
|
||||
|
||||
for (var year in [null, -100, 1917, 2012]) {
|
||||
for (var month in [null, -1, 1, 2, 12, 14]) {
|
||||
for (var day in [null, -1, 1, 28, 29, 30, 31, 32]) {
|
||||
for (var hour in [null, -1, 0, 23, 25]) {
|
||||
for (var minute in [null, -1, 1, 59, 61]) {
|
||||
for (var second in [null, -1, 1, 59, 61]) {
|
||||
for (var millisecond in [null, -1, 1, 999, 1001]) {
|
||||
for (var isUtc in [false, true]) {
|
||||
for (var base in [epoch, dst, leap]) {
|
||||
testCopyWith(
|
||||
base,
|
||||
year,
|
||||
month,
|
||||
day,
|
||||
hour,
|
||||
minute,
|
||||
second,
|
||||
millisecond,
|
||||
isUtc,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
// Copyright (c) 2012, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
// Dart test program for DateTime, extreme values.
|
||||
|
||||
bool get supportsMicroseconds =>
|
||||
new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1;
|
||||
|
||||
// Identical to _maxMillisecondsSinceEpoch in date_time.dart
|
||||
const int _MAX_MILLISECONDS = 8640000000000000;
|
||||
|
||||
void testExtremes() {
|
||||
var dt =
|
||||
new DateTime.fromMillisecondsSinceEpoch(_MAX_MILLISECONDS, isUtc: true);
|
||||
Expect.equals(275760, dt.year);
|
||||
Expect.equals(9, dt.month);
|
||||
Expect.equals(13, dt.day);
|
||||
Expect.equals(0, dt.hour);
|
||||
Expect.equals(0, dt.minute);
|
||||
Expect.equals(0, dt.second);
|
||||
Expect.equals(0, dt.millisecond);
|
||||
Expect.equals(0, dt.microsecond);
|
||||
dt = new DateTime.fromMillisecondsSinceEpoch(-_MAX_MILLISECONDS, isUtc: true);
|
||||
Expect.equals(-271821, dt.year);
|
||||
Expect.equals(4, dt.month);
|
||||
Expect.equals(20, dt.day);
|
||||
Expect.equals(0, dt.hour);
|
||||
Expect.equals(0, dt.minute);
|
||||
Expect.equals(0, dt.second);
|
||||
Expect.equals(0, dt.millisecond);
|
||||
Expect.equals(0, dt.microsecond);
|
||||
// Make sure that we can build the extreme dates in local too.
|
||||
dt = new DateTime.fromMillisecondsSinceEpoch(_MAX_MILLISECONDS);
|
||||
dt = new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute);
|
||||
Expect.equals(_MAX_MILLISECONDS, dt.millisecondsSinceEpoch);
|
||||
dt = new DateTime.fromMillisecondsSinceEpoch(-_MAX_MILLISECONDS);
|
||||
dt = new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute);
|
||||
Expect.equals(-_MAX_MILLISECONDS, dt.millisecondsSinceEpoch);
|
||||
Expect.throws(() => new DateTime.fromMillisecondsSinceEpoch(
|
||||
_MAX_MILLISECONDS + 1,
|
||||
isUtc: true));
|
||||
Expect.throws(() => new DateTime.fromMillisecondsSinceEpoch(
|
||||
-_MAX_MILLISECONDS - 1,
|
||||
isUtc: true));
|
||||
Expect.throws(
|
||||
() => new DateTime.fromMillisecondsSinceEpoch(_MAX_MILLISECONDS + 1));
|
||||
Expect.throws(
|
||||
() => new DateTime.fromMillisecondsSinceEpoch(-_MAX_MILLISECONDS - 1));
|
||||
dt = new DateTime.fromMillisecondsSinceEpoch(_MAX_MILLISECONDS);
|
||||
Expect.throws(
|
||||
() => new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 1));
|
||||
dt = new DateTime.fromMillisecondsSinceEpoch(_MAX_MILLISECONDS, isUtc: true);
|
||||
Expect.throws(() =>
|
||||
new DateTime.utc(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 1));
|
||||
dt = new DateTime.fromMillisecondsSinceEpoch(-_MAX_MILLISECONDS);
|
||||
Expect.throws(
|
||||
() => new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, -1));
|
||||
dt = new DateTime.fromMillisecondsSinceEpoch(-_MAX_MILLISECONDS, isUtc: true);
|
||||
Expect.throws(() =>
|
||||
new DateTime.utc(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, -1));
|
||||
|
||||
if (!supportsMicroseconds) return;
|
||||
|
||||
dt = new DateTime.fromMicrosecondsSinceEpoch(_MAX_MILLISECONDS * 1000);
|
||||
dt = new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute);
|
||||
Expect.equals(_MAX_MILLISECONDS * 1000, dt.microsecondsSinceEpoch);
|
||||
dt = new DateTime.fromMicrosecondsSinceEpoch(-_MAX_MILLISECONDS * 1000);
|
||||
dt = new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute);
|
||||
Expect.equals(-_MAX_MILLISECONDS * 1000, dt.microsecondsSinceEpoch);
|
||||
Expect.throws(() => new DateTime.fromMicrosecondsSinceEpoch(
|
||||
_MAX_MILLISECONDS * 1000 + 1,
|
||||
isUtc: true));
|
||||
Expect.throws(() => new DateTime.fromMicrosecondsSinceEpoch(
|
||||
-_MAX_MILLISECONDS * 1000 - 1,
|
||||
isUtc: true));
|
||||
Expect.throws(() =>
|
||||
new DateTime.fromMicrosecondsSinceEpoch(_MAX_MILLISECONDS * 1000 + 1));
|
||||
Expect.throws(() =>
|
||||
new DateTime.fromMicrosecondsSinceEpoch(-_MAX_MILLISECONDS * 1000 - 1));
|
||||
dt = new DateTime.fromMillisecondsSinceEpoch(_MAX_MILLISECONDS);
|
||||
Expect.throws(() =>
|
||||
new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 0, 1));
|
||||
dt = new DateTime.fromMillisecondsSinceEpoch(_MAX_MILLISECONDS, isUtc: true);
|
||||
Expect.throws(() =>
|
||||
new DateTime.utc(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 0, 1));
|
||||
dt = new DateTime.fromMillisecondsSinceEpoch(-_MAX_MILLISECONDS);
|
||||
Expect.throws(() =>
|
||||
new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 0, -1));
|
||||
dt = new DateTime.fromMillisecondsSinceEpoch(-_MAX_MILLISECONDS, isUtc: true);
|
||||
Expect.throws(() => new DateTime.utc(
|
||||
dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 0, -1));
|
||||
}
|
||||
|
||||
void main() {
|
||||
testExtremes();
|
||||
}
|
|
@ -1,109 +0,0 @@
|
|||
// Copyright (c) 2019, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
// Dart test program for DateTime, far away dates.
|
||||
|
||||
// TODO(37442): Find far-away dates with milliseconds-since-epoch values that
|
||||
// are 'web' integers.
|
||||
|
||||
bool get supportsMicroseconds =>
|
||||
new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1;
|
||||
|
||||
void testFarAwayDates() {
|
||||
DateTime dt =
|
||||
new DateTime.fromMillisecondsSinceEpoch(1000000000000001, isUtc: true);
|
||||
Expect.equals(33658, dt.year);
|
||||
Expect.equals(9, dt.month);
|
||||
Expect.equals(27, dt.day);
|
||||
Expect.equals(1, dt.hour);
|
||||
Expect.equals(46, dt.minute);
|
||||
Expect.equals(40, dt.second);
|
||||
Expect.equals(1, dt.millisecond);
|
||||
Expect.equals(0, dt.microsecond);
|
||||
dt = new DateTime.fromMillisecondsSinceEpoch(-1000000000000001, isUtc: true);
|
||||
Expect.equals(-29719, dt.year);
|
||||
Expect.equals(4, dt.month);
|
||||
Expect.equals(5, dt.day);
|
||||
Expect.equals(22, dt.hour);
|
||||
Expect.equals(13, dt.minute);
|
||||
Expect.equals(19, dt.second);
|
||||
Expect.equals(999, dt.millisecond);
|
||||
Expect.equals(0, dt.microsecond);
|
||||
// Same with local zone.
|
||||
dt = new DateTime.fromMillisecondsSinceEpoch(1000000000000001);
|
||||
Expect.equals(33658, dt.year);
|
||||
Expect.equals(9, dt.month);
|
||||
Expect.equals(true, dt.day == 27 || dt.day == 26);
|
||||
// Not much we can test for local hour.
|
||||
Expect.equals(true, dt.hour >= 0 && dt.hour < 24);
|
||||
// Timezones can have offsets down to 15 minute.
|
||||
Expect.equals(true, dt.minute % 15 == 46 % 15);
|
||||
Expect.equals(40, dt.second);
|
||||
Expect.equals(1, dt.millisecond);
|
||||
Expect.equals(0, dt.microsecond);
|
||||
dt = new DateTime.fromMillisecondsSinceEpoch(-1000000000000001);
|
||||
Expect.equals(-29719, dt.year);
|
||||
Expect.equals(4, dt.month);
|
||||
Expect.equals(true, 5 == dt.day || 6 == dt.day);
|
||||
// Not much we can test for local hour.
|
||||
Expect.equals(true, dt.hour >= 0 && dt.hour < 24);
|
||||
// Timezones can have offsets down to 15 minute.
|
||||
Expect.equals(true, dt.minute % 15 == 13);
|
||||
Expect.equals(19, dt.second);
|
||||
Expect.equals(999, dt.millisecond);
|
||||
Expect.equals(0, dt.microsecond);
|
||||
|
||||
if (!supportsMicroseconds) return;
|
||||
dt =
|
||||
new DateTime.fromMicrosecondsSinceEpoch(1000000000000000001, isUtc: true);
|
||||
Expect.equals(33658, dt.year);
|
||||
Expect.equals(9, dt.month);
|
||||
Expect.equals(27, dt.day);
|
||||
Expect.equals(1, dt.hour);
|
||||
Expect.equals(46, dt.minute);
|
||||
Expect.equals(40, dt.second);
|
||||
Expect.equals(0, dt.millisecond);
|
||||
Expect.equals(1, dt.microsecond);
|
||||
dt = new DateTime.fromMicrosecondsSinceEpoch(-1000000000000000001,
|
||||
isUtc: true);
|
||||
Expect.equals(-29719, dt.year);
|
||||
Expect.equals(4, dt.month);
|
||||
Expect.equals(5, dt.day);
|
||||
Expect.equals(22, dt.hour);
|
||||
Expect.equals(13, dt.minute);
|
||||
Expect.equals(19, dt.second);
|
||||
Expect.equals(999, dt.millisecond);
|
||||
Expect.equals(999, dt.microsecond);
|
||||
// Same with local zone.
|
||||
dt = new DateTime.fromMicrosecondsSinceEpoch(1000000000000000001);
|
||||
Expect.equals(33658, dt.year);
|
||||
Expect.equals(9, dt.month);
|
||||
Expect.equals(true, dt.day == 27 || dt.day == 26);
|
||||
// Not much we can test for local hour.
|
||||
Expect.equals(true, dt.hour >= 0 && dt.hour < 24);
|
||||
// Timezones can have offsets down to 15 minute.
|
||||
Expect.equals(true, dt.minute % 15 == 46 % 15);
|
||||
Expect.equals(40, dt.second);
|
||||
Expect.equals(0, dt.millisecond);
|
||||
Expect.equals(1, dt.microsecond);
|
||||
dt = new DateTime.fromMicrosecondsSinceEpoch(-1000000000000000001);
|
||||
Expect.equals(-29719, dt.year);
|
||||
Expect.equals(4, dt.month);
|
||||
Expect.equals(true, 5 == dt.day || 6 == dt.day);
|
||||
// Not much we can test for local hour.
|
||||
Expect.equals(true, dt.hour >= 0 && dt.hour < 24);
|
||||
// Timezones can have offsets down to 15 minute.
|
||||
Expect.equals(true, dt.minute % 15 == 13);
|
||||
Expect.equals(19, dt.second);
|
||||
Expect.equals(999, dt.millisecond);
|
||||
Expect.equals(999, dt.microsecond);
|
||||
}
|
||||
|
||||
void main() {
|
||||
testFarAwayDates();
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
// The JavaScript Date constructor 'corrects' 2-digit years NN to 19NN.
|
||||
// Verify that a DateTime with year 1 is created correctly.
|
||||
// Regression test for https://github.com/dart-lang/sdk/issues/42894
|
||||
|
||||
main() {
|
||||
var d = new DateTime(1, 0, 1, 0, 0, 0, 0);
|
||||
var d2 = new DateTime(0, 12, 1, 0, 0, 0, 0);
|
||||
|
||||
Expect.equals(d, d2);
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
check(DateTime expected, String str) {
|
||||
DateTime actual = DateTime.parse(str);
|
||||
Expect.equals(expected, actual); // Only checks if they are at the same time.
|
||||
Expect.equals(expected.isUtc, actual.isUtc);
|
||||
}
|
||||
|
||||
bool get supportsMicroseconds =>
|
||||
new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1;
|
||||
|
||||
main() {
|
||||
check(new DateTime(2012, 02, 27, 13, 27), "2012-02-27 13:27:00");
|
||||
if (supportsMicroseconds) {
|
||||
check(new DateTime.utc(2012, 02, 27, 13, 27, 0, 123, 456),
|
||||
"2012-02-27 13:27:00.1234567891234z");
|
||||
check(new DateTime.utc(2012, 02, 27, 13, 27, 0, 123, 456),
|
||||
"2012-02-27 13:27:00,1234567891234z");
|
||||
} else {
|
||||
check(new DateTime.utc(2012, 02, 27, 13, 27, 0, 123, 0),
|
||||
"2012-02-27 13:27:00.1234567891234z");
|
||||
check(new DateTime.utc(2012, 02, 27, 13, 27, 0, 123, 0),
|
||||
"2012-02-27 13:27:00,1234567891234z");
|
||||
}
|
||||
check(new DateTime(2012, 02, 27, 13, 27), "20120227 13:27:00");
|
||||
check(new DateTime(2012, 02, 27, 13, 27), "20120227T132700");
|
||||
check(new DateTime(2012, 02, 27), "20120227");
|
||||
check(new DateTime(2012, 02, 27), "+20120227");
|
||||
check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14Z");
|
||||
check(new DateTime.utc(-12345, 1, 1), "-123450101 00:00:00 Z");
|
||||
check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14+00");
|
||||
check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14+0000");
|
||||
check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14+00:00");
|
||||
check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14 +00:00");
|
||||
|
||||
check(new DateTime.utc(2015, 02, 14, 13, 0, 0, 0), "2015-02-15T00:00+11");
|
||||
check(new DateTime.utc(2015, 02, 14, 13, 0, 0, 0), "2015-02-15T00:00:00+11");
|
||||
check(
|
||||
new DateTime.utc(2015, 02, 14, 13, 0, 0, 0), "2015-02-15T00:00:00+11:00");
|
||||
|
||||
if (supportsMicroseconds) {
|
||||
check(new DateTime.utc(2015, 02, 15, 0, 0, 0, 500, 500),
|
||||
"2015-02-15T00:00:00.500500Z");
|
||||
check(new DateTime.utc(2015, 02, 15, 0, 0, 0, 511, 500),
|
||||
"2015-02-15T00:00:00.511500Z");
|
||||
} else {
|
||||
check(new DateTime.utc(2015, 02, 15, 0, 0, 0, 501),
|
||||
"2015-02-15T00:00:00.501Z");
|
||||
check(new DateTime.utc(2015, 02, 15, 0, 0, 0, 512),
|
||||
"2015-02-15T00:00:00.512Z");
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,13 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
main() {
|
||||
Expect.throwsUnsupportedError(() => double.infinity.ceil());
|
||||
Expect.throwsUnsupportedError(() => double.negativeInfinity.ceil());
|
||||
Expect.throwsUnsupportedError(() => double.nan.ceil());
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
main() {
|
||||
Expect.equals(0, 0.0.ceil());
|
||||
Expect.equals(1, double.minPositive.ceil());
|
||||
Expect.equals(1, (2.0 * double.minPositive).ceil());
|
||||
Expect.equals(1, (1.18e-38).ceil());
|
||||
Expect.equals(1, (1.18e-38 * 2).ceil());
|
||||
Expect.equals(1, 0.49999999999999994.ceil());
|
||||
Expect.equals(1, 0.5.ceil());
|
||||
Expect.equals(1, 0.9999999999999999.ceil());
|
||||
Expect.equals(1, 1.0.ceil());
|
||||
Expect.equals(2, 1.000000000000001.ceil());
|
||||
// The following numbers are on the border of 52 bits.
|
||||
// For example: 4503599627370499 + 0.5 => 4503599627370500.
|
||||
Expect.equals(4503599627370496, 4503599627370496.0.ceil());
|
||||
Expect.equals(4503599627370497, 4503599627370497.0.ceil());
|
||||
Expect.equals(4503599627370498, 4503599627370498.0.ceil());
|
||||
Expect.equals(4503599627370499, 4503599627370499.0.ceil());
|
||||
|
||||
Expect.equals(9007199254740991, 9007199254740991.0.ceil());
|
||||
Expect.equals(9007199254740992, 9007199254740992.0.ceil());
|
||||
Expect.equals(9223372036854775807, double.maxFinite.ceil()); // //# int64: ok
|
||||
|
||||
Expect.equals(0, (-double.minPositive).ceil());
|
||||
Expect.equals(0, (2.0 * -double.minPositive).ceil());
|
||||
Expect.equals(0, (-1.18e-38).ceil());
|
||||
Expect.equals(0, (-1.18e-38 * 2).ceil());
|
||||
Expect.equals(0, (-0.49999999999999994).ceil());
|
||||
Expect.equals(0, (-0.5).ceil());
|
||||
Expect.equals(0, (-0.9999999999999999).ceil());
|
||||
Expect.equals(-1, (-1.0).ceil());
|
||||
Expect.equals(-1, (-1.000000000000001).ceil());
|
||||
Expect.equals(-4503599627370496, (-4503599627370496.0).ceil());
|
||||
Expect.equals(-4503599627370497, (-4503599627370497.0).ceil());
|
||||
Expect.equals(-4503599627370498, (-4503599627370498.0).ceil());
|
||||
Expect.equals(-4503599627370499, (-4503599627370499.0).ceil());
|
||||
Expect.equals(-9007199254740991, (-9007199254740991.0).ceil());
|
||||
Expect.equals(-9007199254740992, (-9007199254740992.0).ceil());
|
||||
Expect.equals(-9223372036854775808, (-double.maxFinite).ceil()); // //# int64: ok
|
||||
|
||||
Expect.isTrue(0.0.ceil() is int);
|
||||
Expect.isTrue(double.minPositive.ceil() is int);
|
||||
Expect.isTrue((2.0 * double.minPositive).ceil() is int);
|
||||
Expect.isTrue((1.18e-38).ceil() is int);
|
||||
Expect.isTrue((1.18e-38 * 2).ceil() is int);
|
||||
Expect.isTrue(0.49999999999999994.ceil() is int);
|
||||
Expect.isTrue(0.5.ceil() is int);
|
||||
Expect.isTrue(0.9999999999999999.ceil() is int);
|
||||
Expect.isTrue(1.0.ceil() is int);
|
||||
Expect.isTrue(1.000000000000001.ceil() is int);
|
||||
Expect.isTrue(4503599627370496.0.ceil() is int);
|
||||
Expect.isTrue(4503599627370497.0.ceil() is int);
|
||||
Expect.isTrue(4503599627370498.0.ceil() is int);
|
||||
Expect.isTrue(4503599627370499.0.ceil() is int);
|
||||
Expect.isTrue(9007199254740991.0.ceil() is int);
|
||||
Expect.isTrue(9007199254740992.0.ceil() is int);
|
||||
Expect.isTrue(double.maxFinite.ceil() is int);
|
||||
|
||||
Expect.isTrue((-double.minPositive).ceil() is int);
|
||||
Expect.isTrue((2.0 * -double.minPositive).ceil() is int);
|
||||
Expect.isTrue((-1.18e-38).ceil() is int);
|
||||
Expect.isTrue((-1.18e-38 * 2).ceil() is int);
|
||||
Expect.isTrue((-0.49999999999999994).ceil() is int);
|
||||
Expect.isTrue((-0.5).ceil() is int);
|
||||
Expect.isTrue((-0.9999999999999999).ceil() is int);
|
||||
Expect.isTrue((-1.0).ceil() is int);
|
||||
Expect.isTrue((-1.000000000000001).ceil() is int);
|
||||
Expect.isTrue((-4503599627370496.0).ceil() is int);
|
||||
Expect.isTrue((-4503599627370497.0).ceil() is int);
|
||||
Expect.isTrue((-4503599627370498.0).ceil() is int);
|
||||
Expect.isTrue((-4503599627370499.0).ceil() is int);
|
||||
Expect.isTrue((-9007199254740991.0).ceil() is int);
|
||||
Expect.isTrue((-9007199254740992.0).ceil() is int);
|
||||
Expect.isTrue((-double.maxFinite).ceil() is int);
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
main() {
|
||||
Expect.equals(0.0, 0.0.ceilToDouble());
|
||||
Expect.equals(1.0, double.minPositive.ceilToDouble());
|
||||
Expect.equals(1.0, (2.0 * double.minPositive).ceilToDouble());
|
||||
Expect.equals(1.0, (1.18e-38).ceilToDouble());
|
||||
Expect.equals(1.0, (1.18e-38 * 2).ceilToDouble());
|
||||
Expect.equals(1.0, 0.49999999999999994.ceilToDouble());
|
||||
Expect.equals(1.0, 0.5.ceilToDouble());
|
||||
Expect.equals(1.0, 0.9999999999999999.ceilToDouble());
|
||||
Expect.equals(1.0, 1.0.ceilToDouble());
|
||||
Expect.equals(2.0, 1.000000000000001.ceilToDouble());
|
||||
// The following numbers are on the border of 52 bits.
|
||||
// For example: 4503599627370499 + 0.5 => 4503599627370500.
|
||||
Expect.equals(4503599627370496.0, 4503599627370496.0.ceilToDouble());
|
||||
Expect.equals(4503599627370497.0, 4503599627370497.0.ceilToDouble());
|
||||
Expect.equals(4503599627370498.0, 4503599627370498.0.ceilToDouble());
|
||||
Expect.equals(4503599627370499.0, 4503599627370499.0.ceilToDouble());
|
||||
|
||||
Expect.equals(9007199254740991.0, 9007199254740991.0.ceilToDouble());
|
||||
Expect.equals(9007199254740992.0, 9007199254740992.0.ceilToDouble());
|
||||
Expect.equals(double.maxFinite, double.maxFinite.ceilToDouble());
|
||||
|
||||
Expect.equals(0.0, (-double.minPositive).ceilToDouble());
|
||||
Expect.equals(0.0, (2.0 * -double.minPositive).ceilToDouble());
|
||||
Expect.equals(0.0, (-1.18e-38).ceilToDouble());
|
||||
Expect.equals(0.0, (-1.18e-38 * 2).ceilToDouble());
|
||||
Expect.equals(0.0, (-0.49999999999999994).ceilToDouble());
|
||||
Expect.equals(0.0, (-0.5).ceilToDouble());
|
||||
Expect.equals(0.0, (-0.9999999999999999).ceilToDouble());
|
||||
Expect.equals(-1.0, (-1.0).ceilToDouble());
|
||||
Expect.equals(-1.0, (-1.000000000000001).ceilToDouble());
|
||||
Expect.equals(-4503599627370496.0, (-4503599627370496.0).ceilToDouble());
|
||||
Expect.equals(-4503599627370497.0, (-4503599627370497.0).ceilToDouble());
|
||||
Expect.equals(-4503599627370498.0, (-4503599627370498.0).ceilToDouble());
|
||||
Expect.equals(-4503599627370499.0, (-4503599627370499.0).ceilToDouble());
|
||||
Expect.equals(-9007199254740991.0, (-9007199254740991.0).ceilToDouble());
|
||||
Expect.equals(-9007199254740992.0, (-9007199254740992.0).ceilToDouble());
|
||||
Expect.equals(-double.maxFinite, (-double.maxFinite).ceilToDouble());
|
||||
|
||||
Expect.equals(double.infinity, double.infinity.ceilToDouble());
|
||||
Expect.equals(
|
||||
double.negativeInfinity, double.negativeInfinity.ceilToDouble());
|
||||
Expect.isTrue(double.nan.ceilToDouble().isNaN);
|
||||
|
||||
Expect.isTrue(0.0.ceilToDouble() is double);
|
||||
Expect.isTrue(double.minPositive.ceilToDouble() is double);
|
||||
Expect.isTrue((2.0 * double.minPositive).ceilToDouble() is double);
|
||||
Expect.isTrue((1.18e-38).ceilToDouble() is double);
|
||||
Expect.isTrue((1.18e-38 * 2).ceilToDouble() is double);
|
||||
Expect.isTrue(0.49999999999999994.ceilToDouble() is double);
|
||||
Expect.isTrue(0.5.ceilToDouble() is double);
|
||||
Expect.isTrue(0.9999999999999999.ceilToDouble() is double);
|
||||
Expect.isTrue(1.0.ceilToDouble() is double);
|
||||
Expect.isTrue(1.000000000000001.ceilToDouble() is double);
|
||||
Expect.isTrue(4503599627370496.0.ceilToDouble() is double);
|
||||
Expect.isTrue(4503599627370497.0.ceilToDouble() is double);
|
||||
Expect.isTrue(4503599627370498.0.ceilToDouble() is double);
|
||||
Expect.isTrue(4503599627370499.0.ceilToDouble() is double);
|
||||
Expect.isTrue(9007199254740991.0.ceilToDouble() is double);
|
||||
Expect.isTrue(9007199254740992.0.ceilToDouble() is double);
|
||||
Expect.isTrue(double.maxFinite.ceilToDouble() is double);
|
||||
|
||||
Expect.isTrue((-double.minPositive).ceilToDouble().isNegative);
|
||||
Expect.isTrue((2.0 * -double.minPositive).ceilToDouble().isNegative);
|
||||
Expect.isTrue((-1.18e-38).ceilToDouble().isNegative);
|
||||
Expect.isTrue((-1.18e-38 * 2).ceilToDouble().isNegative);
|
||||
Expect.isTrue((-0.49999999999999994).ceilToDouble().isNegative);
|
||||
Expect.isTrue((-0.5).ceilToDouble().isNegative);
|
||||
Expect.isTrue((-0.9999999999999999).ceilToDouble().isNegative);
|
||||
|
||||
Expect.isTrue((-double.minPositive).ceilToDouble() is double);
|
||||
Expect.isTrue((2.0 * -double.minPositive).ceilToDouble() is double);
|
||||
Expect.isTrue((-1.18e-38).ceilToDouble() is double);
|
||||
Expect.isTrue((-1.18e-38 * 2).ceilToDouble() is double);
|
||||
Expect.isTrue((-0.49999999999999994).ceilToDouble() is double);
|
||||
Expect.isTrue((-0.5).ceilToDouble() is double);
|
||||
Expect.isTrue((-0.9999999999999999).ceilToDouble() is double);
|
||||
Expect.isTrue((-1.0).ceilToDouble() is double);
|
||||
Expect.isTrue((-1.000000000000001).ceilToDouble() is double);
|
||||
Expect.isTrue((-4503599627370496.0).ceilToDouble() is double);
|
||||
Expect.isTrue((-4503599627370497.0).ceilToDouble() is double);
|
||||
Expect.isTrue((-4503599627370498.0).ceilToDouble() is double);
|
||||
Expect.isTrue((-4503599627370499.0).ceilToDouble() is double);
|
||||
Expect.isTrue((-9007199254740991.0).ceilToDouble() is double);
|
||||
Expect.isTrue((-9007199254740992.0).ceilToDouble() is double);
|
||||
Expect.isTrue((-double.maxFinite).ceilToDouble() is double);
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
// Copyright (c) 2011, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
// Dart test program for testing 'compare' on doubles.
|
||||
|
||||
void main() {
|
||||
Expect.equals(0, (0.0).compareTo(0.0));
|
||||
Expect.equals(0, (1.0).compareTo(1.0));
|
||||
Expect.equals(0, (-2.0).compareTo(-2.0));
|
||||
Expect.equals(0, (1e-50).compareTo(1e-50));
|
||||
Expect.equals(0, (-2e50).compareTo(-2e50));
|
||||
Expect.equals(0, double.nan.compareTo(double.nan));
|
||||
Expect.equals(0, double.infinity.compareTo(double.infinity));
|
||||
Expect.equals(0, double.negativeInfinity.compareTo(double.negativeInfinity));
|
||||
Expect.equals(0, (-0.0).compareTo(-0.0));
|
||||
Expect.isTrue((0.0).compareTo(1.0) < 0);
|
||||
Expect.isTrue((1.0).compareTo(0.0) > 0);
|
||||
Expect.isTrue((0.0).compareTo(-1.0) > 0);
|
||||
Expect.isTrue((-1.0).compareTo(0.0) < 0);
|
||||
Expect.isTrue((0.0).compareTo(1234e11) < 0);
|
||||
Expect.isTrue((123e-112).compareTo(0.0) > 0);
|
||||
Expect.isTrue((0.0).compareTo(-123.0e12) > 0);
|
||||
Expect.isTrue((-1.0e8).compareTo(0.0) < 0);
|
||||
|
||||
double maxDouble = 1.7976931348623157e308;
|
||||
Expect.equals(0, maxDouble.compareTo(maxDouble));
|
||||
Expect.isTrue(maxDouble.compareTo(double.infinity) < 0);
|
||||
Expect.isTrue(double.infinity.compareTo(maxDouble) > 0);
|
||||
|
||||
double negMaxDouble = -maxDouble;
|
||||
Expect.equals(0, negMaxDouble.compareTo(negMaxDouble));
|
||||
Expect.isTrue(double.negativeInfinity.compareTo(negMaxDouble) < 0);
|
||||
Expect.isTrue(negMaxDouble.compareTo(double.negativeInfinity) > 0);
|
||||
|
||||
Expect.isTrue((-0.0).compareTo(0.0) < 0);
|
||||
Expect.isTrue((0.0).compareTo(-0.0) > 0);
|
||||
Expect.isTrue(double.nan.compareTo(double.infinity) > 0);
|
||||
Expect.isTrue(double.nan.compareTo(double.negativeInfinity) > 0);
|
||||
Expect.isTrue(double.infinity.compareTo(double.nan) < 0);
|
||||
Expect.isTrue(double.negativeInfinity.compareTo(double.nan) < 0);
|
||||
Expect.isTrue(maxDouble.compareTo(double.nan) < 0);
|
||||
Expect.isTrue(negMaxDouble.compareTo(double.nan) < 0);
|
||||
Expect.isTrue(double.nan.compareTo(maxDouble) > 0);
|
||||
Expect.isTrue(double.nan.compareTo(negMaxDouble) > 0);
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
main() {
|
||||
Expect.throwsUnsupportedError(() => double.infinity.floor());
|
||||
Expect.throwsUnsupportedError(() => double.negativeInfinity.floor());
|
||||
Expect.throwsUnsupportedError(() => double.nan.floor());
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
main() {
|
||||
Expect.equals(0, 0.0.floor());
|
||||
Expect.equals(0, double.minPositive.floor());
|
||||
Expect.equals(0, (2.0 * double.minPositive).floor());
|
||||
Expect.equals(0, (1.18e-38).floor());
|
||||
Expect.equals(0, (1.18e-38 * 2).floor());
|
||||
Expect.equals(0, 0.49999999999999994.floor());
|
||||
Expect.equals(0, 0.5.floor());
|
||||
Expect.equals(0, 0.9999999999999999.floor());
|
||||
Expect.equals(1, 1.0.floor());
|
||||
Expect.equals(1, 1.000000000000001.floor());
|
||||
// The following numbers are on the border of 52 bits.
|
||||
// For example: 4503599627370499 + 0.5 => 4503599627370500.
|
||||
Expect.equals(4503599627370496, 4503599627370496.0.floor());
|
||||
Expect.equals(4503599627370497, 4503599627370497.0.floor());
|
||||
Expect.equals(4503599627370498, 4503599627370498.0.floor());
|
||||
Expect.equals(4503599627370499, 4503599627370499.0.floor());
|
||||
|
||||
Expect.equals(9007199254740991, 9007199254740991.0.floor());
|
||||
Expect.equals(9007199254740992, 9007199254740992.0.floor());
|
||||
Expect.equals(9223372036854775807, double.maxFinite.floor()); // //# int64: ok
|
||||
|
||||
Expect.equals(-1, (-double.minPositive).floor());
|
||||
Expect.equals(-1, (2.0 * -double.minPositive).floor());
|
||||
Expect.equals(-1, (-1.18e-38).floor());
|
||||
Expect.equals(-1, (-1.18e-38 * 2).floor());
|
||||
Expect.equals(-1, (-0.49999999999999994).floor());
|
||||
Expect.equals(-1, (-0.5).floor());
|
||||
Expect.equals(-1, (-0.9999999999999999).floor());
|
||||
Expect.equals(-1, (-1.0).floor());
|
||||
Expect.equals(-2, (-1.000000000000001).floor());
|
||||
Expect.equals(-4503599627370496, (-4503599627370496.0).floor());
|
||||
Expect.equals(-4503599627370497, (-4503599627370497.0).floor());
|
||||
Expect.equals(-4503599627370498, (-4503599627370498.0).floor());
|
||||
Expect.equals(-4503599627370499, (-4503599627370499.0).floor());
|
||||
Expect.equals(-9007199254740991, (-9007199254740991.0).floor());
|
||||
Expect.equals(-9007199254740992, (-9007199254740992.0).floor());
|
||||
Expect.equals(-9223372036854775808, (-double.maxFinite).floor()); // //# int64: ok
|
||||
|
||||
Expect.isTrue(0.0.floor() is int);
|
||||
Expect.isTrue(double.minPositive.floor() is int);
|
||||
Expect.isTrue((2.0 * double.minPositive).floor() is int);
|
||||
Expect.isTrue((1.18e-38).floor() is int);
|
||||
Expect.isTrue((1.18e-38 * 2).floor() is int);
|
||||
Expect.isTrue(0.49999999999999994.floor() is int);
|
||||
Expect.isTrue(0.5.floor() is int);
|
||||
Expect.isTrue(0.9999999999999999.floor() is int);
|
||||
Expect.isTrue(1.0.floor() is int);
|
||||
Expect.isTrue(1.000000000000001.floor() is int);
|
||||
Expect.isTrue(4503599627370496.0.floor() is int);
|
||||
Expect.isTrue(4503599627370497.0.floor() is int);
|
||||
Expect.isTrue(4503599627370498.0.floor() is int);
|
||||
Expect.isTrue(4503599627370499.0.floor() is int);
|
||||
Expect.isTrue(9007199254740991.0.floor() is int);
|
||||
Expect.isTrue(9007199254740992.0.floor() is int);
|
||||
Expect.isTrue(double.maxFinite.floor() is int);
|
||||
|
||||
Expect.isTrue((-double.minPositive).floor() is int);
|
||||
Expect.isTrue((2.0 * -double.minPositive).floor() is int);
|
||||
Expect.isTrue((-1.18e-38).floor() is int);
|
||||
Expect.isTrue((-1.18e-38 * 2).floor() is int);
|
||||
Expect.isTrue((-0.49999999999999994).floor() is int);
|
||||
Expect.isTrue((-0.5).floor() is int);
|
||||
Expect.isTrue((-0.9999999999999999).floor() is int);
|
||||
Expect.isTrue((-1.0).floor() is int);
|
||||
Expect.isTrue((-1.000000000000001).floor() is int);
|
||||
Expect.isTrue((-4503599627370496.0).floor() is int);
|
||||
Expect.isTrue((-4503599627370497.0).floor() is int);
|
||||
Expect.isTrue((-4503599627370498.0).floor() is int);
|
||||
Expect.isTrue((-4503599627370499.0).floor() is int);
|
||||
Expect.isTrue((-9007199254740991.0).floor() is int);
|
||||
Expect.isTrue((-9007199254740992.0).floor() is int);
|
||||
Expect.isTrue((-double.maxFinite).floor() is int);
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
main() {
|
||||
Expect.equals(0.0, 0.0.floorToDouble());
|
||||
Expect.equals(0.0, double.minPositive.floorToDouble());
|
||||
Expect.equals(0.0, (2.0 * double.minPositive).floorToDouble());
|
||||
Expect.equals(0.0, (1.18e-38).floorToDouble());
|
||||
Expect.equals(0.0, (1.18e-38 * 2).floorToDouble());
|
||||
Expect.equals(0.0, 0.49999999999999994.floorToDouble());
|
||||
Expect.equals(0.0, 0.5.floorToDouble());
|
||||
Expect.equals(0.0, 0.9999999999999999.floorToDouble());
|
||||
Expect.equals(1.0, 1.0.floorToDouble());
|
||||
Expect.equals(1.0, 1.000000000000001.floorToDouble());
|
||||
// The following numbers are on the border of 52 bits.
|
||||
// For example: 4503599627370499 + 0.5 => 4503599627370500.
|
||||
Expect.equals(4503599627370496.0, 4503599627370496.0.floorToDouble());
|
||||
Expect.equals(4503599627370497.0, 4503599627370497.0.floorToDouble());
|
||||
Expect.equals(4503599627370498.0, 4503599627370498.0.floorToDouble());
|
||||
Expect.equals(4503599627370499.0, 4503599627370499.0.floorToDouble());
|
||||
|
||||
Expect.equals(9007199254740991.0, 9007199254740991.0.floorToDouble());
|
||||
Expect.equals(9007199254740992.0, 9007199254740992.0.floorToDouble());
|
||||
Expect.equals(double.maxFinite, double.maxFinite.floorToDouble());
|
||||
|
||||
Expect.equals(-1.0, (-double.minPositive).floorToDouble());
|
||||
Expect.equals(-1.0, (2.0 * -double.minPositive).floorToDouble());
|
||||
Expect.equals(-1.0, (-1.18e-38).floorToDouble());
|
||||
Expect.equals(-1.0, (-1.18e-38 * 2).floorToDouble());
|
||||
Expect.equals(-1.0, (-0.49999999999999994).floorToDouble());
|
||||
Expect.equals(-1.0, (-0.5).floorToDouble());
|
||||
Expect.equals(-1.0, (-0.9999999999999999).floorToDouble());
|
||||
Expect.equals(-1.0, (-1.0).floorToDouble());
|
||||
Expect.equals(-2.0, (-1.000000000000001).floorToDouble());
|
||||
Expect.equals(-4503599627370496.0, (-4503599627370496.0).floorToDouble());
|
||||
Expect.equals(-4503599627370497.0, (-4503599627370497.0).floorToDouble());
|
||||
Expect.equals(-4503599627370498.0, (-4503599627370498.0).floorToDouble());
|
||||
Expect.equals(-4503599627370499.0, (-4503599627370499.0).floorToDouble());
|
||||
Expect.equals(-9007199254740991.0, (-9007199254740991.0).floorToDouble());
|
||||
Expect.equals(-9007199254740992.0, (-9007199254740992.0).floorToDouble());
|
||||
Expect.equals(-double.maxFinite, (-double.maxFinite).floorToDouble());
|
||||
|
||||
Expect.equals(double.infinity, double.infinity.floorToDouble());
|
||||
Expect.equals(
|
||||
double.negativeInfinity, double.negativeInfinity.floorToDouble());
|
||||
Expect.isTrue(double.nan.floorToDouble().isNaN);
|
||||
|
||||
Expect.isTrue(0.0.floorToDouble() is double);
|
||||
Expect.isTrue(double.minPositive.floorToDouble() is double);
|
||||
Expect.isTrue((2.0 * double.minPositive).floorToDouble() is double);
|
||||
Expect.isTrue((1.18e-38).floorToDouble() is double);
|
||||
Expect.isTrue((1.18e-38 * 2).floorToDouble() is double);
|
||||
Expect.isTrue(0.49999999999999994.floorToDouble() is double);
|
||||
Expect.isTrue(0.5.floorToDouble() is double);
|
||||
Expect.isTrue(0.9999999999999999.floorToDouble() is double);
|
||||
Expect.isTrue(1.0.floorToDouble() is double);
|
||||
Expect.isTrue(1.000000000000001.floorToDouble() is double);
|
||||
Expect.isTrue(4503599627370496.0.floorToDouble() is double);
|
||||
Expect.isTrue(4503599627370497.0.floorToDouble() is double);
|
||||
Expect.isTrue(4503599627370498.0.floorToDouble() is double);
|
||||
Expect.isTrue(4503599627370499.0.floorToDouble() is double);
|
||||
Expect.isTrue(9007199254740991.0.floorToDouble() is double);
|
||||
Expect.isTrue(9007199254740992.0.floorToDouble() is double);
|
||||
Expect.isTrue(double.maxFinite.floorToDouble() is double);
|
||||
|
||||
Expect.isTrue((-double.minPositive).floorToDouble() is double);
|
||||
Expect.isTrue((2.0 * -double.minPositive).floorToDouble() is double);
|
||||
Expect.isTrue((-1.18e-38).floorToDouble() is double);
|
||||
Expect.isTrue((-1.18e-38 * 2).floorToDouble() is double);
|
||||
Expect.isTrue((-0.49999999999999994).floorToDouble() is double);
|
||||
Expect.isTrue((-0.5).floorToDouble() is double);
|
||||
Expect.isTrue((-0.9999999999999999).floorToDouble() is double);
|
||||
Expect.isTrue((-1.0).floorToDouble() is double);
|
||||
Expect.isTrue((-1.000000000000001).floorToDouble() is double);
|
||||
Expect.isTrue((-4503599627370496.0).floorToDouble() is double);
|
||||
Expect.isTrue((-4503599627370497.0).floorToDouble() is double);
|
||||
Expect.isTrue((-4503599627370498.0).floorToDouble() is double);
|
||||
Expect.isTrue((-4503599627370499.0).floorToDouble() is double);
|
||||
Expect.isTrue((-9007199254740991.0).floorToDouble() is double);
|
||||
Expect.isTrue((-9007199254740992.0).floorToDouble() is double);
|
||||
Expect.isTrue((-double.maxFinite).floorToDouble() is double);
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
// Copyright (c) 2017, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
// VMOptions=--intrinsify --use_sse41
|
||||
// VMOptions=--no_intrinsify --use_sse41
|
||||
// VMOptions=--intrinsify --no_use_sse41
|
||||
// VMOptions=--no_intrinsify --no_use_sse41
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
main() {
|
||||
for (int x in [0, 1, 0xffff, 0xffffffff, 0x111111111111, 0xffffffffffff]) {
|
||||
test(x);
|
||||
test(-x);
|
||||
}
|
||||
|
||||
// Test with ints outside the 53-bit range that are known to have an
|
||||
// exact double representation.
|
||||
test(9007199254840856);
|
||||
test(144115188075954880);
|
||||
test(936748722493162112);
|
||||
test(0x8000000000000000);
|
||||
}
|
||||
|
||||
test(int x) {
|
||||
Expect.equals(x, x.toDouble().toInt(), "bad test argument ($x)");
|
||||
Expect.equals(x.hashCode, x.toDouble().hashCode);
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,13 +0,0 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
main() {
|
||||
Expect.throwsUnsupportedError(() => double.infinity.round());
|
||||
Expect.throwsUnsupportedError(() => double.negativeInfinity.round());
|
||||
Expect.throwsUnsupportedError(() => double.nan.round());
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue