about summary refs log tree commit diff stats
path: root/061text.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-11-23 14:01:07 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-11-23 14:01:07 -0800
commitca4210b479603ccc25b274d7c3489eac0f9a22d6 (patch)
tree88a779ba90878f3993e14a942bd168476aeaa866 /061text.mu
parent6f69d5d9af1860ce1a9dff9f89c2aafa5a3e6dac (diff)
downloadmu-ca4210b479603ccc25b274d7c3489eac0f9a22d6.tar.gz
3683
Diffstat (limited to '061text.mu')
-rw-r--r--061text.mu26
1 files changed, 26 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]