Skip to content

Commit

Permalink
#993. Added tests for Abi class
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov committed Feb 25, 2022
1 parent 971ac72 commit 9a3da0a
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 0 deletions.
18 changes: 18 additions & 0 deletions LibTest/ffi/Abi/Abi.current_A01_t01.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// 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.

/// @assertion Abi.current()
/// The ABI the Dart VM is currently running on.
///
/// @description Checks that this method returns the ABI the Dart VM is
/// currently running on
/// @author sgrekhov@unipro.ru
import "dart:ffi";
import "../../../Utils/expect.dart";

main() {
final abi = Abi.current();
Expect.isTrue(Abi.values.contains(abi));
}
55 changes: 55 additions & 0 deletions LibTest/ffi/Abi/Abi.current_A01_t02.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// 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.

/// @assertion Abi.current()
/// The ABI the Dart VM is currently running on.
///
/// @description Checks that this method returns the ABI the Dart VM is
/// currently running on
/// @author sgrekhov@unipro.ru
import "dart:ffi";
import 'dart:io';
import "../../../Utils/expect.dart";

main() {
final abi = Abi.current();
Expect.isTrue(Abi.values.contains(abi));
if (Platform.isAndroid) {
Expect.isTrue(
abi == Abi.androidArm ||
abi == Abi.androidArm64 ||
abi == Abi.androidIA32 ||
abi == Abi.androidX64,
abi.toString());
}
if (Platform.isFuchsia) {
Expect.isTrue(
abi == Abi.fuchsiaArm64 || abi == Abi.fuchsiaX64, abi.toString());
}
if (Platform.isIOS) {
Expect.isTrue(abi == Abi.iosArm || abi == Abi.iosArm64 || abi == Abi.iosX64,
abi.toString());
}
if (Platform.isLinux) {
Expect.isTrue(
abi == Abi.linuxArm ||
abi == Abi.linuxArm64 ||
abi == Abi.linuxX64 ||
abi == Abi.linuxIA32 ||
abi == Abi.linuxRiscv32 ||
abi == Abi.linuxRiscv64,
abi.toString());
}
if (Platform.isMacOS) {
Expect.isTrue(abi == Abi.macosX64 || abi == Abi.macosArm64, abi.toString());
}
if (Platform.isWindows) {
Expect.isTrue(
abi == Abi.windowsArm64 ||
abi == Abi.windowsIA32 ||
abi == Abi.windowsX64,
abi.toString());
}
}
27 changes: 27 additions & 0 deletions LibTest/ffi/Abi/Abi.toString_A01_t01.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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.

/// @assertion @override
/// String toString()
/// override
/// A string representation of this ABI.
///
// The string is equal to the 'on' part from Platform.version and dart --version
///
/// @description Checks that this method returns a string which is equal to the
/// 'on' part from Platform.version
/// @author sgrekhov@unipro.ru
import "dart:ffi";
import 'dart:io';
import "../../../Utils/expect.dart";

main() {
final abi = Abi.current();
String expected = Platform.version
.substring(Platform.version.indexOf(" on ") + 4)
.trim()
.replaceAll("\"", "");
Expect.equals(expected, abi.toString());
}
25 changes: 25 additions & 0 deletions LibTest/ffi/Abi/Abi.values_A01_t01.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 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.

/// @assertion values constant Null safety
/// List<Abi> const values
/// The ABIs that the DartVM can run on.
///
/// Does not contain a macosIA32. We have stopped supporting 32-bit MacOS.
///
/// Includes windowsArm64, even though it is currently not supported. Support
/// has been requested for Flutter.
/// https://github.com/flutter/flutter/issues/53120
///
/// @description Checks that this list contains `windowsArm64` and the current
/// ABI
/// @author sgrekhov@unipro.ru
import "dart:ffi";
import "../../../Utils/expect.dart";

main() {
Expect.isTrue(Abi.values.contains(Abi.current()));
Expect.isTrue(Abi.values.contains(Abi.windowsArm64));
}

0 comments on commit 9a3da0a

Please sign in to comment.