diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-07-11 14:13:43 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-07-11 14:14:16 -0700 |
| commit | ba2b83d5669f9fcf6f49fcd2adac5997eb07f7d8 (patch) | |
| tree | 55d0ecaafd6c5c871bd987a28a2b61fca16b250c /core/collections.nom | |
| parent | b32634faf8eb0fe1448ca44ddf9b3a6bfaf20b68 (diff) | |
Fixed nomsu codegen for indented text and improved text parsing. Also
moved some more tests inline.
Diffstat (limited to 'core/collections.nom')
| -rw-r--r-- | core/collections.nom | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/core/collections.nom b/core/collections.nom index 367356b..94fc02c 100644 --- a/core/collections.nom +++ b/core/collections.nom @@ -182,6 +182,15 @@ compile [%dict with fallback %key -> %value] to end}) # Sorting +test + %x <- [3,1,2] + sort %x + assume: %x = [1,2,3] + sort %x by % = (-%) + assume: %x = [3,2,1] + %keys <- {1:999,2:0,3:50} + sort %x by % = %keys.% + assume: %x = [2,3,1] compile [sort %items] to: Lua "table.sort(\(%items as lua expr));" parse [..] sort %items by %item = %key_expr @@ -193,6 +202,7 @@ parse [..] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +test: assume: (sorted [3,1,2]) = [1,2,3] action [%items sorted, sorted %items] %copy <- (% for % in %items) sort %copy @@ -206,6 +216,7 @@ parse [..] sort %copy by %item = %key return %copy +test: assume: (unique [1,2,1,3,2,3]) = [1,2,3] action [unique %items] %unique <- [] %seen <- {} |
