Skip to content

Commit 2babc5f

Browse files
committed
FIX: throw error on invalid image! construction syntax
related to: Oldes/Rebol-issues#1034
1 parent 02296f0 commit 2babc5f

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/core/t-image.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ INLINE REBCNT ARGB_To_BGR(REBCNT i)
637637
if ((w = Valid_Tuples(block))) Trap_Arg(block+w-1);
638638
Tuples_To_RGBA(ip, size, VAL_BLK_DATA(block), VAL_LEN(block));
639639
}
640-
else if (!IS_END(block)) return 0;
640+
if (!IS_END(block)) return 0;
641641

642642
//if (!IS_END(block)) Trap_Arg(block);
643643

src/tests/units/image-test.r3

+36
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,42 @@ Rebol [
2222
--assert-er try [image? to image! make gob! []]
2323
===end-group===
2424

25+
===start-group=== "construct image"
26+
--test-- "construct image valid"
27+
--assert "make image! [1x1 #{FFFFFF}]" = mold #[image! 1x1]
28+
--assert "make image! [1x1 #{FFFFFF}]" = mold #[image! 1x1 #{FFFFFF}]
29+
--assert "make image! [1x1 #{FFFFFF}]" = mold #[image! 1x1 #{FF}]
30+
--assert "make image! [1x1 #{141414}]" = mold #[image! 1x1 20.20.20]
31+
--assert "make image! [1x1 #{141414} #{3C}]" = mold #[image! 1x1 20.20.20.60]
32+
--assert all [
33+
"make image! [1x1 #{FFFFFF} #{30}]" = mold img: #[image! 1x1 #{FFFFFF} #{30}]
34+
#{30} = img/alpha
35+
#{FFFFFF} = img/rgb
36+
#{FFFFFF30} = img/rgba
37+
]
38+
--assert all [
39+
"make image! [1x1 #{}]" = mold img: #[image! 1x1 #{FFFFFF} 2]
40+
2 = index? img
41+
#{} = img/alpha
42+
#{} = img/rgba
43+
img: head img
44+
"make image! [1x1 #{FFFFFF}]" = mold img
45+
#{FF} = img/alpha
46+
#{FFFFFFFF} = img/rgba
47+
]
48+
--test-- "construct image invalid"
49+
;@@ https://github.com/Oldes/Rebol-issues/issues/1034
50+
--assert error? try [load {#[image!]}]
51+
--assert error? try [load {#[image! x]}]
52+
--assert error? try [load {#[image! 1x-1]}]
53+
--assert error? try [load {#[image! 1x1 x]}]
54+
--assert error? try [load {#[image! 1x1 #{FF} x]}]
55+
--assert error? try [load {#[image! 1x1 20.20.20.60 x]}]
56+
--assert error? try [load {#[image! 1x1 #{FFFFFF} #{30} x]}]
57+
58+
59+
===end-group===
60+
2561
===start-group=== "FOREACH"
2662
--test-- "issue-1479"
2763
;@@ https://github.com/Oldes/Rebol-issues/issues/1479

0 commit comments

Comments
 (0)