dart-sdk/tests/ffi_2/abi_test.dart
Daco Harkes 663357209c [vm/ffi] Introduce Abi
This introduces the application binary interface (ABI) concept to
`dart:ffi` as a class with opaque instances.

We will use this for providing mappings for ABI-specific types.
Bug: https://github.com/dart-lang/sdk/issues/42563
Bug: https://github.com/dart-lang/sdk/issues/42816
Closes: https://github.com/dart-lang/sdk/issues/45254

Later, we might open up the contents of `Abi` if need be.

Some API design discussion notes:
https://github.com/dart-lang/sdk/issues/42563#issuecomment-981774001

TEST=tests/ffi/abi_test.dart

Change-Id: Iebf290fc12f37d6f4236432ddf27ab3e12bde06d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221627
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-12-01 19:19:37 +00:00

26 lines
732 B
Dart

// 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
import 'dart:ffi';
import 'dart:io';
import 'package:expect/expect.dart';
void main() {
testCurrent();
testPlatformVersionCompatibility();
}
void testCurrent() {
final currentAbi = Abi.current();
Expect.isTrue(Abi.values.contains(currentAbi));
}
void testPlatformVersionCompatibility() {
final abiStringFromPlatformVersion = Platform.version.split('"')[1];
final abiStringFromCurrent = Abi.current().toString();
Expect.equals(abiStringFromPlatformVersion, abiStringFromCurrent);
}