Skip to content

Commit 83b36ec

Browse files
committed
update tests
Signed-off-by: Jade Abraham <jade.abraham@hpe.com>
1 parent 9f84bbc commit 83b36ec

14 files changed

+33
-23
lines changed

test/hash/throwingHash.chpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ record myRec: hashable {
33

44
proc hash(salt = 0): uint throws {
55
// This is not meant to be a good hash function, just to test throwing
6-
if (salt == 0) then throw new IllegalArgumentError("salt too obvious!");
6+
if salt == 0 then throw new IllegalArgumentError("salt too obvious!");
77
else return x*salt;
88
}
99
}

test/hash/throwingHashCallsRef.future

Lines changed: 0 additions & 2 deletions
This file was deleted.

test/hash/throwingHashCallsRef.good

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/hash/throwingHashInModule.bad

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/hash/throwingHashInModule.chpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module throwingHashInModule { // module decl essential to exhibit the problem
44

55
proc hash(salt = 0): uint throws {
66
// This is not meant to be a good hash function, just to test throwing
7-
if (salt == 0) then throw new IllegalArgumentError("salt too obvious!");
7+
if salt == 0 then throw new IllegalArgumentError("salt too obvious!");
88
else return x*salt;
99
}
1010
}

test/hash/throwingHashInModule.future

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module throwingHashInModule { // module decl essential to exhibit the problem
2+
record myRec: hashable {
3+
var x: int;
4+
5+
proc hash(salt = 0): uint {
6+
// This is not meant to be a good hash function, just to test throwing
7+
if salt == 0 then throw new IllegalArgumentError("salt too obvious!");
8+
else return x*salt;
9+
}
10+
}
11+
12+
proc main() {
13+
var myR = new myRec(15);
14+
try {
15+
var hash1 = myR.hash();
16+
} catch e: IllegalArgumentError {
17+
writeln(e.message());
18+
var hash2 = try! myR.hash(3);
19+
writeln(hash2);
20+
} catch e {
21+
halt(e.message());
22+
}
23+
}
24+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
throwingHashInModuleError.chpl:5: In method 'hash':
2+
throwingHashInModuleError.chpl:7: error: cannot throw in a non-throwing function

test/hash/throwingHashIndirect.chpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ record myRec: hashable {
44
var x: int;
55

66
proc checkSaltArg(salt) throws {
7-
if (salt == 0) then throw new IllegalArgumentError("salt too obvious!");
7+
if salt == 0 then throw new IllegalArgumentError("salt too obvious!");
88
}
99

1010
proc hash(salt = 0): uint throws {

test/hash/throwingHashRef.bad

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)