File tree 2 files changed +37
-11
lines changed
2 files changed +37
-11
lines changed Original file line number Diff line number Diff line change 181
181
REBINT n = 0 ;
182
182
REBD32 x1 , x2 = 0.0 ;
183
183
REBD32 y1 , y2 = 0.0 ;
184
+ REBINT x , y ;
184
185
185
186
val = D_ARG (1 );
186
187
x1 = VAL_PAIR_X (val );
239
240
else {
240
241
switch (action ) {
241
242
242
- #ifdef temp
243
- case A_ODDQ :
244
- DECIDE ((x1 & 1 ) && (y1 & 1 ));
245
-
246
- case A_EVENQ :
247
- DECIDE ((x1 & 1 ) == 0 && (y1 & 1 ) == 0 );
248
- #endif
249
243
case A_NEGATE :
250
244
x1 = - x1 ;
251
245
y1 = - y1 ;
345
339
return R_RET ;
346
340
}
347
341
Trap_Make (REB_PAIR , val );
342
+
343
+ case A_ODDQ :
344
+ case A_EVENQ :
345
+ x = VAL_PAIR_X_INT (val ) & 1 ;
346
+ y = VAL_PAIR_Y_INT (val ) & 1 ;
347
+ if (action == A_ODDQ )
348
+ DECIDE (x && y );
349
+ else
350
+ DECIDE (x == 0 && y == 0 );
351
+
348
352
}
349
353
}
350
354
Trap_Action (REB_PAIR , action );
355
359
VAL_PAIR_Y (DS_RETURN ) = y1 ;
356
360
return R_RET ;
357
361
358
- // is_false:
359
- // return R_FALSE;
362
+ is_false :
363
+ return R_FALSE ;
360
364
361
- // is_true:
362
- // return R_TRUE;
365
+ is_true :
366
+ return R_TRUE ;
363
367
}
364
368
Original file line number Diff line number Diff line change @@ -238,6 +238,28 @@ Rebol [
238
238
239
239
===end-group===
240
240
241
+ ===start-group=== "pair - even?/odd?"
242
+ ;@@ https://github.com/Oldes/Rebol-issues/issues/1884
243
+ --test-- "odd?"
244
+ --assert not odd? 0x0
245
+ --assert not odd? 0x1
246
+ --assert not odd? 1x0
247
+ --assert odd? 1x1
248
+ --assert not odd? 2x2
249
+ --assert odd? 1.1x2.9
250
+ --assert not odd? 1.1x2.2
251
+
252
+ --test-- "even?"
253
+ --assert even? 0x0
254
+ --assert not even? 0x1
255
+ --assert not even? 1x0
256
+ --assert not even? 1x1
257
+ --assert even? 2x2
258
+ --assert even? 1.9x2.1
259
+ --assert not even? 1.1x2.2
260
+
261
+ ===end-group===
262
+
241
263
===start-group=== "pair - issues"
242
264
243
265
--test-- "invalid construction"
You can’t perform that action at this time.
0 commit comments