Skip to content

Commit

Permalink
Fix DEFAULT of not set bug, add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hostilefork committed Jul 6, 2016
1 parent dee59da commit 49371ea
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/mezz/base-infix.r
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ default: enfix function [
value
"The value" ; void not allowed on purpose
][
unless all [gotten: get/opt target | not blank? gotten] [
unless all [any-value? gotten: get/opt target | not blank? gotten] [
set target value
]
; return value should never be used...the SET-WORD! or SET-PATH!
Expand Down
23 changes: 23 additions & 0 deletions tests/core-tests.r
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,29 @@
[1 == do reduce [:abs -1]]


; DEFAULT tests

[
unset 'x
x: default 10
x = 10
][
x: _
x: default 10
x = 10
][
x: 20
x: default 10
x = 20
][
o: make object! [x: 10 y: _ z: ()]
o/x: default 20
o/y: default 20
o/z: default 20
[10 20 20] = reduce [o/x o/y o/z]
]


; better-than-nothing VARARGS! variadic argument tests

[
Expand Down

0 comments on commit 49371ea

Please sign in to comment.