-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#993. DynamicLibrary constructors tests added
- Loading branch information
Sergey G. Grekhov
committed
Feb 4, 2021
1 parent
06ef7ae
commit 7473e25
Showing
8 changed files
with
142 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
LibTest/ffi/DynamicLibrary/DynamicLibrary.executable_A01_t01.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* 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. | ||
*/ | ||
/** | ||
* @assertion DynamicLibrary.executable() | ||
* Creates a dynamic library representing the running executable. | ||
* | ||
* @description Checks that this constructor creates a dynamic library | ||
* representing the running executable | ||
* @author sgrekhov@unipro.ru | ||
*/ | ||
import "dart:ffi"; | ||
import "../../../Utils/expect.dart"; | ||
|
||
void main() { | ||
DynamicLibrary dl = new DynamicLibrary.executable(); | ||
Expect.isNotNull(dl); | ||
Expect.isNotNull(dl.lookup("Dart_Invoke")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
LibTest/ffi/DynamicLibrary/DynamicLibrary.open_A02_t01.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* 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. | ||
*/ | ||
/** | ||
* @assertion DynamicLibrary.open(String name) | ||
* Loads a dynamic library file with local visibility. | ||
* | ||
* Throws an ArgumentError if loading the dynamic library fails. | ||
* | ||
* Calling this function multiple times, even in different isolates, returns | ||
* objects which are equal but not identical. The underlying library is only | ||
* loaded once into the DartVM by the OS. | ||
* | ||
* @description Checks that an ArgumentError if loading the dynamic library | ||
* fails | ||
* @author sgrekhov@unipro.ru | ||
*/ | ||
import "dart:ffi"; | ||
import "../ffi_utils.dart"; | ||
import "../../../Utils/expect.dart"; | ||
|
||
void main() { | ||
Expect.throws(() { | ||
new DynamicLibrary.open("Wrong path"); | ||
}, (e) => e is ArgumentError); | ||
} |
31 changes: 31 additions & 0 deletions
31
LibTest/ffi/DynamicLibrary/DynamicLibrary.open_A03_t01.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* 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. | ||
*/ | ||
/** | ||
* @assertion DynamicLibrary.open(String name) | ||
* Loads a dynamic library file with local visibility. | ||
* | ||
* Throws an ArgumentError if loading the dynamic library fails. | ||
* | ||
* Calling this function multiple times, even in different isolates, returns | ||
* objects which are equal but not identical. The underlying library is only | ||
* loaded once into the DartVM by the OS. | ||
* | ||
* @description Checks that calling this function multiple times, even in | ||
* different isolates, returns objects which are equal but not identical | ||
* @author sgrekhov@unipro.ru | ||
*/ | ||
import "dart:ffi"; | ||
import "../ffi_utils.dart"; | ||
import "../../../Utils/expect.dart"; | ||
|
||
void main() { | ||
final path = libPath("ffi_test_dynamic_library"); | ||
DynamicLibrary dl1 = new DynamicLibrary.open(path); | ||
DynamicLibrary dl2 = new DynamicLibrary.open(path); | ||
Expect.equals(dl1, dl2); | ||
Expect.isTrue(dl1 == dl2); | ||
Expect.isFalse(identical(dl1, dl2)); | ||
} |
30 changes: 30 additions & 0 deletions
30
LibTest/ffi/DynamicLibrary/DynamicLibrary.process_A01_t01.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* 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. | ||
*/ | ||
/** | ||
* @assertion DynamicLibrary.process() | ||
* Creates a dynamic library holding all global symbols. | ||
* | ||
* Any symbol in a library currently loaded with global visibility (including | ||
* the executable itself) may be resolved in this library. | ||
* | ||
* This feature is not available on Windows, instead an exception is thrown. | ||
* | ||
* @description Checks that this constructor creates a dynamic library | ||
* holding all global symbol | ||
* @author sgrekhov@unipro.ru | ||
*/ | ||
import "dart:ffi"; | ||
import 'dart:io' show Platform; | ||
import "../../../Utils/expect.dart"; | ||
|
||
void main() { | ||
if (!Platform.isWindows) { | ||
DynamicLibrary dl = new DynamicLibrary.process(); | ||
Expect.isNotNull(dl); | ||
Expect.isNotNull(dl.lookup("Dart_Invoke")); | ||
Expect.isNotNull(dl.lookup("printf")); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
LibTest/ffi/DynamicLibrary/DynamicLibrary.process_A02_t01.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* 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. | ||
*/ | ||
/** | ||
* @assertion DynamicLibrary.process() | ||
* Creates a dynamic library holding all global symbols. | ||
* | ||
* Any symbol in a library currently loaded with global visibility (including | ||
* the executable itself) may be resolved in this library. | ||
* | ||
* This feature is not available on Windows, instead an exception is thrown. | ||
* | ||
* @description Checks that this throws an exception on Windows | ||
* @author sgrekhov@unipro.ru | ||
*/ | ||
import "dart:ffi"; | ||
import 'dart:io' show Platform; | ||
import "../../../Utils/expect.dart"; | ||
|
||
void main() { | ||
if (Platform.isWindows) { | ||
Expect.throws(() { | ||
new DynamicLibrary.process(); | ||
}); | ||
} | ||
} |