@@ -172,6 +172,7 @@ public Collection<? extends Snippet> createValueConstructors(Context context) {
172
172
"bool:True" , BOOL , "True" ,
173
173
"bool:False" , BOOL , "False" ,
174
174
"int" , INT , "1" ,
175
+ // "int:0", INT, "0", // disabled due to GR-45046
175
176
"float" , FLOAT , "1.1" ,
176
177
"complex" , COMPLEX , "1.0j" ,
177
178
"str" , STR , "class pstr(str):\n pass\n pstr('hello world')" ,
@@ -522,8 +523,12 @@ public void accept(SnippetRun snippetRun) throws PolyglotException {
522
523
Value par0 = parameters .get (0 );
523
524
Value par1 = parameters .get (1 );
524
525
525
- // If anumber/Boolean should be divided, ignore if divisor is Boolean false
526
- if (!par0 .isNumber () && !par0 .isBoolean () || !par1 .isBoolean () || par1 .asBoolean ()) {
526
+ // If a number should be divided by 0 or false, expect an exception
527
+ if ((par0 .isNumber () || par0 .isBoolean ()) && (par1 .isBoolean () && par1 .asBoolean () == false || par1 .isNumber () && par1 .fitsInInt () && par1 .asInt () == 0 )) {
528
+ if (snippetRun .getException () == null || !snippetRun .getException ().getMessage ().contains ("division by zero" )) {
529
+ throw new AssertionError ("Division by 0 should have raised" );
530
+ }
531
+ } else {
527
532
ResultVerifier .getDefaultResultVerifier ().accept (snippetRun );
528
533
}
529
534
}
0 commit comments