-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduces the Map pseudodatastructure
The Map uses the Set for its list of keys, then hijacks the shell variable namespace to store the mappings for each key. Keys must be, therefore, valid variable names. This might change in the future when we introduce hashing. Changes were made to exp, dump and toenv to also work with it.
- Loading branch information
Showing
4 changed files
with
112 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright (c) Alexandre Gomes Gaigalas <[email protected]> | ||
# SPDX-License-Identifier: ISC | ||
|
||
test_Map_noargs () { | ||
Map | ||
eval deref=\$$_R | ||
tap_assert "" "$deref" | ||
} | ||
|
||
test_Map_simple () { | ||
Map :mykey myvalue | ||
eval deref=\$$_R | ||
tap_assert "mykey" "$deref" | ||
eval deref=\$${_R}imykey | ||
tap_assert "myvalue" "$deref" | ||
} | ||
|
||
test_Map_multiple_keys () { | ||
Map :mykey myvalue :mysecond anothervalue | ||
eval deref=\$$_R | ||
tap_assert "mykey${__EOL__}mysecond" "$deref" | ||
eval deref=\$${_R}imysecond | ||
tap_assert "anothervalue" "$deref" | ||
} | ||
|
||
test_Map_add_to_existing () { | ||
Map :mykey myvalue | ||
Map_add $_R :mysecond anothervalue | ||
eval deref=\$$_R | ||
tap_assert "mykey${__EOL__}mysecond" "$deref" | ||
eval deref=\$${_R}imysecond | ||
tap_assert "anothervalue" "$deref" | ||
} | ||
|
||
test_Map_key_uniqueness_retains_last_value () { | ||
Map :mykey myvalue :mykey whichvalue | ||
eval deref=\$$_R | ||
tap_assert "mykey" "$deref" | ||
eval deref=\$${_R}imykey | ||
tap_assert "whichvalue" "$deref" | ||
} |
File renamed without changes.
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