-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fixed the deparsing of the prefix-colon operator. (fixes #84)
Thanks to Cat Stevens (@catb0t) for finding and reporting this issue.
- Loading branch information
Showing
5 changed files
with
67 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/ruby | ||
|
||
# Test the prefix-colon operator `:(...)`. | ||
# https://github.com/trizen/sidef/issues/84 | ||
|
||
class X { | ||
has Hash colon_inner = Hash( | ||
:prop => :(:k => :v) | ||
) | ||
|
||
has Hash colon_outer = :( | ||
:prop => Hash(:k => :v) | ||
) | ||
|
||
has Hash colon_both = :( | ||
:prop => :(:k, :v) | ||
) | ||
|
||
has Hash colon_none = Hash( | ||
:prop => Hash(:k, :v) | ||
) | ||
} | ||
|
||
func g { | ||
var Hash y = :(:k, :()) | ||
return y | ||
} | ||
|
||
var x = X() | ||
|
||
var expect = Hash("prop" => Hash("k" => "v")) | ||
|
||
assert_eq(x.colon_inner, expect) | ||
assert_eq(x.colon_outer, expect) | ||
assert_eq(x.colon_both, expect) | ||
assert_eq(x.colon_none, expect) | ||
|
||
var Hash h = :(:k => :()) | ||
|
||
assert_eq(h, Hash("k" => Hash())) | ||
assert_eq(g(), Hash("k" => Hash())) | ||
|
||
assert_eq(x.colon_outer\{:prop}, Hash("k" => "v")) | ||
|
||
say "** Test passed!" |