diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-11-23 14:01:07 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-11-23 14:01:07 -0800 |
commit | ca4210b479603ccc25b274d7c3489eac0f9a22d6 (patch) | |
tree | 88a779ba90878f3993e14a942bd168476aeaa866 | |
parent | 6f69d5d9af1860ce1a9dff9f89c2aafa5a3e6dac (diff) | |
download | mu-ca4210b479603ccc25b274d7c3489eac0f9a22d6.tar.gz |
3683
-rw-r--r-- | 061text.mu | 26 | ||||
-rw-r--r-- | html/061text.mu.html | 26 |
2 files changed, 52 insertions, 0 deletions
diff --git a/061text.mu b/061text.mu index 62f67a7b..bd7eb89f 100644 --- a/061text.mu +++ b/061text.mu @@ -3,6 +3,11 @@ def equal a:text, b:text -> result:bool [ local-scope load-ingredients + an:num, bn:num <- copy a, b + address-equal?:boolean <- equal an, bn + reply-if address-equal?, 1/true + reply-unless a, 0/false + reply-unless b, 0/false a-len:num <- length *a b-len:num <- length *b # compare lengths @@ -84,6 +89,27 @@ scenario text-equal-with-empty [ ] ] +scenario text-equal-with-null [ + local-scope + x:text <- new [abcd] + y:text <- copy 0 + run [ + 10:bool/raw <- equal x, 0 + 11:bool/raw <- equal 0, x + 12:bool/raw <- equal x, y + 13:bool/raw <- equal y, x + 14:bool/raw <- equal y, y + ] + memory-should-contain [ + 10 <- 0 + 11 <- 0 + 12 <- 0 + 13 <- 0 + 14 <- 1 + ] + check-trace-count-for-label 0, [error] +] + scenario text-equal-common-lengths-but-distinct [ local-scope x:text <- new [abc] diff --git a/html/061text.mu.html b/html/061text.mu.html index 95ad7a28..5f9ba882 100644 --- a/html/061text.mu.html +++ b/html/061text.mu.html @@ -37,6 +37,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> equal a:text, b:text<span class="muRecipe"> -> </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> + an:num, bn:num <span class="Special"><-</span> copy a, b + address-equal?:boolean <span class="Special"><-</span> equal an, bn + <span class="muControl">reply-if</span> address-equal?, <span class="Constant">1/true</span> + <span class="muControl">reply-unless</span> a, <span class="Constant">0/false</span> + <span class="muControl">reply-unless</span> b, <span class="Constant">0/false</span> a-len:num <span class="Special"><-</span> length *a b-len:num <span class="Special"><-</span> length *b <span class="Comment"># compare lengths</span> @@ -118,6 +123,27 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] ] +<span class="muScenario">scenario</span> text-equal-with-null [ + <span class="Constant">local-scope</span> + x:text <span class="Special"><-</span> new <span class="Constant">[abcd]</span> + y:text <span class="Special"><-</span> copy<span class="Constant"> 0</span> + run [ + 10:bool/<span class="Special">raw</span> <span class="Special"><-</span> equal x,<span class="Constant"> 0</span> + 11:bool/<span class="Special">raw</span> <span class="Special"><-</span> equal<span class="Constant"> 0</span>, x + 12:bool/<span class="Special">raw</span> <span class="Special"><-</span> equal x, y + 13:bool/<span class="Special">raw</span> <span class="Special"><-</span> equal y, x + 14:bool/<span class="Special">raw</span> <span class="Special"><-</span> equal y, y + ] + memory-should-contain [ + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 0</span> + <span class="Constant"> 11</span> <span class="Special"><-</span><span class="Constant"> 0</span> + <span class="Constant"> 12</span> <span class="Special"><-</span><span class="Constant"> 0</span> + <span class="Constant"> 13</span> <span class="Special"><-</span><span class="Constant"> 0</span> + <span class="Constant"> 14</span> <span class="Special"><-</span><span class="Constant"> 1</span> + ] + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[error]</span> +] + <span class="muScenario">scenario</span> text-equal-common-lengths-but-distinct [ <span class="Constant">local-scope</span> x:text <span class="Special"><-</span> new <span class="Constant">[abc]</span> |