12
12
import static org .junit .Assert .assertEquals ;
13
13
import static org .junit .Assert .assertFalse ;
14
14
import static org .junit .Assert .assertTrue ;
15
- import static org .junit . Assert . fail ;
15
+ import static org .truffleruby . RubyTest . assertThrows ;
16
16
17
17
import org .junit .Test ;
18
18
import org .truffleruby .core .array .library .ArrayStoreLibrary ;
@@ -32,12 +32,9 @@ public void delegatedArrayLibraryOnlyAcceptsSpecificStore() {
32
32
assertFalse (library .accepts (longDelegated ));
33
33
34
34
assertEquals (42 , library .read (intDelegated , 0 ));
35
- try {
36
- library .read (longDelegated , 0 );
37
- fail ();
38
- } catch (AssertionError e ) {
39
- assertTrue (e .getMessage ().contains ("Library does not accept given receiver" ));
40
- }
35
+
36
+ var e = assertThrows (() -> library .read (longDelegated , 0 ), AssertionError .class );
37
+ assertTrue (e .getMessage ().contains ("Library does not accept given receiver" ));
41
38
}
42
39
43
40
@ Test
@@ -51,12 +48,9 @@ public void sharedArrayLibraryOnlyAcceptsSpecificStore() {
51
48
assertFalse (library .accepts (longShared ));
52
49
53
50
assertEquals (42 , library .read (intShared , 0 ));
54
- try {
55
- library .read (longShared , 0 );
56
- fail ();
57
- } catch (AssertionError e ) {
58
- assertTrue (e .getMessage ().contains ("Library does not accept given receiver" ));
59
- }
51
+
52
+ var e = assertThrows (() -> library .read (longShared , 0 ), AssertionError .class );
53
+ assertTrue (e .getMessage ().contains ("Library does not accept given receiver" ));
60
54
}
61
55
62
56
@ Test
0 commit comments