Skip to content

Commit e10e98d

Browse files
committed
FIX: objects equality
resolves: Oldes/Rebol-issues#1133
1 parent e0ede96 commit e10e98d

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

src/core/t-object.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static REBOOL Same_Object(REBVAL *val, REBVAL *arg)
4141
}
4242

4343

44-
static REBOOL Equal_Object(REBVAL *val, REBVAL *arg)
44+
static REBOOL Equal_Object(REBVAL *val, REBVAL *arg, REBFLG is_case)
4545
{
4646
REBSER *f1;
4747
REBSER *f2;
@@ -64,9 +64,9 @@ static REBOOL Equal_Object(REBVAL *val, REBVAL *arg)
6464
for (n = 1; n < (REBINT)(f1->tail); n++) {
6565
if (VAL_HIDDEN(BLK_SKIP(w1, n))) return VAL_HIDDEN(BLK_SKIP(w2, n));
6666
if (VAL_HIDDEN(BLK_SKIP(w2, n))) return VAL_HIDDEN(BLK_SKIP(w1, n));
67-
if (Cmp_Value(BLK_SKIP(w1, n), BLK_SKIP(w2, n), FALSE)) return FALSE;
67+
if (Cmp_Value(BLK_SKIP(w1, n), BLK_SKIP(w2, n), is_case)) return FALSE;
6868
// Use Compare_Values();
69-
if (Cmp_Value(BLK_SKIP(f1, n), BLK_SKIP(f2, n), FALSE)) return FALSE;
69+
if (Cmp_Value(BLK_SKIP(f1, n), BLK_SKIP(f2, n), is_case)) return FALSE;
7070
}
7171

7272
return TRUE;
@@ -231,7 +231,7 @@ static REBSER *Trim_Object(REBSER *obj)
231231
{
232232
if (mode < 0) return -1;
233233
if (mode == 3) return Same_Object(a, b);
234-
return Equal_Object(a, b);
234+
return Equal_Object(a, b, mode > 1);
235235
}
236236

237237

src/tests/units/compare-test.r3

+22
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,28 @@ Rebol [
226226

227227
===end-group===
228228

229+
230+
===start-group=== "object!"
231+
;@@ https://github.com/Oldes/Rebol-issues/issues/1133
232+
--test-- "equal? objects with numeric values"
233+
--assert equal? construct [c: 1] construct [c: 1]
234+
--assert equal? construct [c: 1] construct [c: 1.0]
235+
--assert equal? construct [c: 1] construct [c: $1]
236+
--assert equal? construct [c: 1] construct [c: 100%]
237+
--assert equal? construct [c: 1.0] construct [c: 1]
238+
--assert equal? construct [c: $1] construct [c: 1]
239+
--assert equal? construct [c: 100%] construct [c: 1]
240+
--test-- "strict-equal? objects with numeric values"
241+
--assert strict-equal? construct [c: 1] construct [c: 1]
242+
--assert not strict-equal? construct [c: 1] construct [c: 1.0]
243+
--assert not strict-equal? construct [c: 1] construct [c: $1]
244+
--assert not strict-equal? construct [c: 1] construct [c: 100%]
245+
--assert not strict-equal? construct [c: 1.0] construct [c: 1]
246+
--assert not strict-equal? construct [c: $1] construct [c: 1]
247+
--assert not strict-equal? construct [c: 100%] construct [c: 1]
248+
===end-group===
249+
250+
229251
;- tests from Red Language...
230252
===start-group=== "prefix equal same datatype"
231253
--test-- "prefix-equal-same-datatype-1" --assert equal? 0 0

0 commit comments

Comments
 (0)