Skip to content

Commit

Permalink
Issue #1094: changes from master moved to pre-nnbd branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
iarkh committed Aug 9, 2021
1 parent a291f91 commit d7cbaa8
Show file tree
Hide file tree
Showing 42 changed files with 593 additions and 315 deletions.
17 changes: 13 additions & 4 deletions LibTest/io/RandomAccessFile/lockSync_A01_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,35 @@ import "../file_utils.dart";
import "lock_check_1_lib.dart";

void check(int fLen) {
String eScript = Platform.script.toString();
File file = getTempFileSync();
asyncStart();
var rf = file.openSync(mode: FileMode.write);
rf.writeFromSync(new List.filled(fLen, 1));
rf.lockSync(FileLock.exclusive);
Expect.isTrue(fLen == rf.lengthSync());
var tests = [
() => checkLocked(rf.path),
() => checkLocked(rf.path, 0, fLen, FileLock.shared)
() => checkLocked(eScript, rf.path),
() => checkLocked(eScript, rf.path, 0, fLen, FileLock.shared)
];
Future.forEach(tests, (f) => f()).whenComplete(() {
Future.forEach(tests, (Function f) => f()).whenComplete(() {
asyncEnd();
rf.unlockSync();
rf.closeSync();
file.deleteSync();
});
}

main() {
runMain() {
check(10);
check(100);
check(1000);
}

main(List<String> args) {
if(args.length > 0)
runProcess(args);
else {
runMain();
}
}
18 changes: 14 additions & 4 deletions LibTest/io/RandomAccessFile/lockSync_A01_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,36 @@ import "../file_utils.dart";
import "lock_check_1_lib.dart";

void check(int fLen) {

File file = getTempFileSync();
asyncStart();
var rf = file.openSync(mode: FileMode.write);
rf.writeFromSync(new List.filled(fLen, 1));
rf.lockSync(FileLock.shared);
Expect.isTrue(fLen == rf.lengthSync());
String eScript = Platform.script.toString();
var tests = [
() => checkLocked(rf.path),
() => checkUnlocked(rf.path, 0, fLen, FileLock.shared)
() => checkLocked(eScript, rf.path),
() => checkUnlocked(eScript, rf.path, 0, fLen, FileLock.shared)
];
Future.forEach(tests, (f) => f()).whenComplete(() {
Future.forEach(tests, (Function f) => f()).whenComplete(() {
asyncEnd();
rf.unlockSync();
rf.closeSync();
file.deleteSync();
});
}

main() {
runMain() {
check(10);
check(100);
check(1000);
}

main(List<String> args) {
if(args.length > 0)
runProcess(args);
else {
runMain();
}
}
19 changes: 14 additions & 5 deletions LibTest/io/RandomAccessFile/lockSync_A02_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ void check(int fLen) {
var start = fLen >> 1;
var end = fLen - 2;
rf.lockSync(FileLock.exclusive, start, end);
String eScript = Platform.script.toString();
var tests = [
() => checkLocked(rf.path, start, end),
() => checkUnlocked(rf.path, 0, start),
() => checkUnlocked(rf.path, end, fLen)
() => checkLocked(eScript, rf.path, start, end),
() => checkUnlocked(eScript, rf.path, 0, start),
() => checkUnlocked(eScript, rf.path, end, fLen)
];
Future.forEach(tests, (f) => f()).whenComplete(() {
Future.forEach(tests, (Function f) => f()).whenComplete(() {
asyncEnd();
if (Platform.isWindows) {
rf.unlockSync(start, end);
Expand All @@ -53,8 +54,16 @@ void check(int fLen) {
});
}

main() {
runMain() {
check(10);
check(100);
check(1000);
}

main(List<String> args) {
if(args.length > 0)
runProcess(args);
else {
runMain();
}
}
17 changes: 13 additions & 4 deletions LibTest/io/RandomAccessFile/lockSync_A02_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,29 @@ void check(int fLen) {
var rf = file.openSync(mode: FileMode.write);
rf.writeFromSync(new List.filled(fLen, 1));
rf.lockSync(FileLock.exclusive);
String eScript = Platform.script.toString();
var tests = [
() => checkLocked(rf.path),
() => checkLocked(rf.path, fLen, fLen + 10)
() => checkLocked(eScript, rf.path),
() => checkLocked(eScript, rf.path, fLen, fLen + 10)
];
Future.forEach(tests, (f) => f()).whenComplete(() {
Future.forEach(tests, (Function f) => f()).whenComplete(() {
asyncEnd();
rf.unlockSync();
rf.closeSync();
file.deleteSync();
});
}

main() {
runMain() {
check(10);
check(100);
check(1000);
}

main(List<String> args) {
if(args.length > 0)
runProcess(args);
else {
runMain();
}
}
19 changes: 14 additions & 5 deletions LibTest/io/RandomAccessFile/lockSync_A02_t03.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ void check(int fLen) {
var start = fLen >> 1;
rf.lockSync(FileLock.exclusive, start);
rf.writeFromSync(new List.filled(fLen, 2));
String eScript = Platform.script.toString();
var tests = [
() => checkLocked(rf.path, start),
() => checkUnlocked(rf.path, 0, start),
() => checkLocked(rf.path, fLen, fLen + fLen)
() => checkLocked(eScript, rf.path, start),
() => checkUnlocked(eScript, rf.path, 0, start),
() => checkLocked(eScript, rf.path, fLen, fLen + fLen)
];
Future.forEach(tests, (f) => f()).whenComplete(() {
Future.forEach(tests, (Function f) => f()).whenComplete(() {
asyncEnd();
if (Platform.isWindows) {
rf.unlockSync(start);
Expand All @@ -53,8 +54,16 @@ void check(int fLen) {
});
}

main() {
runMain() {
check(10);
check(100);
check(1000);
}

main(List<String> args) {
if(args.length > 0)
runProcess(args);
else {
runMain();
}
}
19 changes: 14 additions & 5 deletions LibTest/io/RandomAccessFile/lockSync_A02_t04.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ void check(int fLen) {
var start = fLen >> 1;
var end = rf.lengthSync() + 11;
rf.lockSync(FileLock.exclusive, start, end);
String eScript = Platform.script.toString();
var tests = [
() => checkLocked(rf.path, start, end),
() => checkUnlocked(rf.path, 0, start),
() => checkUnlocked(rf.path, end)
() => checkLocked(eScript, rf.path, start, end),
() => checkUnlocked(eScript, rf.path, 0, start),
() => checkUnlocked(eScript, rf.path, end)
];
Future.forEach(tests, (f) => f()).whenComplete(() {
Future.forEach(tests, (Function f) => f()).whenComplete(() {
asyncEnd();
if (Platform.isWindows) {
rf.unlockSync(start, end);
Expand All @@ -53,8 +54,16 @@ void check(int fLen) {
});
}

main() {
runMain() {
check(10);
check(100);
check(1000);
}

main(List<String> args) {
if(args.length > 0)
runProcess(args);
else {
runMain();
}
}
17 changes: 14 additions & 3 deletions LibTest/io/RandomAccessFile/lockSync_A03_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,27 @@ void check(int fLen) {
rf.writeFromSync(new List.filled(fLen, 1));
asyncStart();
rf.lockSync(FileLock.exclusive);
var tests = [() => checkLocked(rf.path, 0, fLen, FileLock.exclusive)];
Future.forEach(tests, (f) => f()).whenComplete(() {
var tests = [
() => checkLocked(
Platform.script.toString(), rf.path, 0, fLen, FileLock.exclusive)
];
Future.forEach(tests, (Function f) => f()).whenComplete(() {
asyncEnd();
rf.unlockSync();
rf.closeSync();
file.deleteSync();
});
}

main() {
runMain() {
check(10);
check(1000);
}

main(List<String> args) {
if (args.length > 0)
runProcess(args);
else {
runMain();
}
}
17 changes: 13 additions & 4 deletions LibTest/io/RandomAccessFile/lockSync_A03_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,28 @@ void check(int fLen) {
var rf = file.openSync(mode: FileMode.read);
asyncStart();
rf.lockSync(FileLock.shared);
String eScript = Platform.script.toString();
var tests = [
() => checkUnlocked(rf.path, 0, fLen, FileLock.shared),
() => checkLocked(rf.path, 0, fLen, FileLock.exclusive)
() => checkUnlocked(eScript, rf.path, 0, fLen, FileLock.shared),
() => checkLocked(eScript, rf.path, 0, fLen, FileLock.exclusive)
];
Future.forEach(tests, (f) => f()).whenComplete(() {
Future.forEach(tests, (Function f) => f()).whenComplete(() {
asyncEnd();
rf.unlockSync();
rf.closeSync();
file.deleteSync();
});
}

main() {
runMain() {
check(10);
check(1000);
}

main(List<String> args) {
if (args.length > 0)
runProcess(args);
else {
runMain();
}
}
16 changes: 13 additions & 3 deletions LibTest/io/RandomAccessFile/lockSync_A03_t03.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,28 @@ import "../../../Utils/expect.dart";
import "../file_utils.dart";
import "lock_check_2_lib.dart";

main() {
runMain() {
int fLen = 10;
File file = getTempFileSync();
file.writeAsBytesSync(new List.filled(fLen, 1));
var rf = file.openSync(mode: FileMode.read);
asyncStart();
var tests = [
() => checkLock(rf.path, 0, fLen, FileLock.exclusive, locked: false)
() => checkLock(
Platform.script.toString(), rf.path, 0, fLen, FileLock.exclusive,
locked: false)
];
Future.forEach(tests, (f) => f()).whenComplete(() {
Future.forEach(tests, (Function f) => f()).whenComplete(() {
asyncEnd();
rf.closeSync();
file.deleteSync();
});
}

main(List<String> args) {
if (args.length > 0)
runProcess(args);
else {
runMain();
}
}
17 changes: 14 additions & 3 deletions LibTest/io/RandomAccessFile/lockSync_A04_t01.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,27 @@ void check(int fLen) {
var rf = file.openSync(mode: FileMode.write);
rf.writeFromSync(new List.filled(fLen, 1));
rf.lockSync(FileLock.exclusive);
var tests = [() => checkLocked(rf.path, 0, -1, FileLock.shared)];
Future.forEach(tests, (f) => f()).whenComplete(() {
var tests = [
() =>
checkLocked(Platform.script.toString(), rf.path, 0, -1, FileLock.shared)
];
Future.forEach(tests, (Function f) => f()).whenComplete(() {
asyncEnd();
rf.unlockSync();
rf.closeSync();
file.deleteSync();
});
}

main() {
runMain() {
check(10);
check(1000);
}

main(List<String> args) {
if (args.length > 0)
runProcess(args);
else {
runMain();
}
}
17 changes: 14 additions & 3 deletions LibTest/io/RandomAccessFile/lockSync_A04_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,27 @@ void check(int fLen) {
var rf = file.openSync(mode: FileMode.write);
rf.writeFromSync(new List.filled(fLen, 1));
rf.lockSync(FileLock.exclusive);
var tests = [() => checkLocked(rf.path, 0, -1, FileLock.exclusive)];
Future.forEach(tests, (f) => f()).whenComplete(() {
var tests = [
() => checkLocked(
Platform.script.toString(), rf.path, 0, -1, FileLock.exclusive)
];
Future.forEach(tests, (Function f) => f()).whenComplete(() {
asyncEnd();
rf.unlockSync();
rf.closeSync();
file.deleteSync();
});
}

main() {
runMain() {
check(10);
check(1000);
}

main(List<String> args) {
if (args.length > 0)
runProcess(args);
else {
runMain();
}
}
Loading

0 comments on commit d7cbaa8

Please sign in to comment.