about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-11-09 07:28:49 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-11-09 07:28:49 -0800
commita459208291ffea063cd532cf2ab5b6adf27d80b7 (patch)
tree20071d895458989477f308c6c092931080f022aa
parentcc39b738c5c4d7ebaa334d6fe21e782aaeb96f65 (diff)
downloadmu-a459208291ffea063cd532cf2ab5b6adf27d80b7.tar.gz
copy back some tests from linux/
-rw-r--r--403unicode.mu57
1 files changed, 57 insertions, 0 deletions
diff --git a/403unicode.mu b/403unicode.mu
index 5f5935c6..73f44a58 100644
--- a/403unicode.mu
+++ b/403unicode.mu
@@ -297,6 +297,33 @@ fn read-grapheme in: (addr stream byte) -> _/eax: grapheme {
   return result
 }
 
+fn test-read-grapheme {
+  var s: (stream byte 0x30)
+  var s2/ecx: (addr stream byte) <- address s
+  write s2, "aΒc世d界e"
+  var c/eax: grapheme <- read-grapheme s2
+  var n/eax: int <- copy c
+  check-ints-equal n, 0x61, "F - test grapheme/0"
+  var c/eax: grapheme <- read-grapheme s2
+  var n/eax: int <- copy c
+  check-ints-equal n, 0x92ce/greek-capital-letter-beta, "F - test grapheme/1"
+  var c/eax: grapheme <- read-grapheme s2
+  var n/eax: int <- copy c
+  check-ints-equal n, 0x63, "F - test grapheme/2"
+  var c/eax: grapheme <- read-grapheme s2
+  var n/eax: int <- copy c
+  check-ints-equal n, 0x96b8e4, "F - test grapheme/3"
+  var c/eax: grapheme <- read-grapheme s2
+  var n/eax: int <- copy c
+  check-ints-equal n, 0x64, "F - test grapheme/4"
+  var c/eax: grapheme <- read-grapheme s2
+  var n/eax: int <- copy c
+  check-ints-equal n, 0x8c95e7, "F - test grapheme/5"
+  var c/eax: grapheme <- read-grapheme s2
+  var n/eax: int <- copy c
+  check-ints-equal n, 0x65, "F - test grapheme/6"
+}
+
 fn grapheme-length g: grapheme -> _/edx: int {
   {
     compare g, 0xff
@@ -332,6 +359,36 @@ fn shift-left-bytes n: int, k: int -> _/eax: int {
   return result
 }
 
+fn test-shift-left-bytes-0 {
+  var result/eax: int <- shift-left-bytes 1, 0
+  check-ints-equal result, 1, "F - shift-left-bytes 0"
+}
+
+fn test-shift-left-bytes-1 {
+  var result/eax: int <- shift-left-bytes 1, 1
+  check-ints-equal result, 0x100, "F - shift-left-bytes 1"
+}
+
+fn test-shift-left-bytes-2 {
+  var result/eax: int <- shift-left-bytes 1, 2
+  check-ints-equal result, 0x10000, "F - shift-left-bytes 2"
+}
+
+fn test-shift-left-bytes-3 {
+  var result/eax: int <- shift-left-bytes 1, 3
+  check-ints-equal result, 0x1000000, "F - shift-left-bytes 3"
+}
+
+fn test-shift-left-bytes-4 {
+  var result/eax: int <- shift-left-bytes 1, 4
+  check-ints-equal result, 0, "F - shift-left-bytes 4"
+}
+
+fn test-shift-left-bytes-5 {
+  var result/eax: int <- shift-left-bytes 1, 5
+  check-ints-equal result, 0, "F - shift-left-bytes >4"
+}
+
 # write a grapheme to a stream of bytes
 # this is like write-to-stream, except we skip leading 0 bytes
 fn write-grapheme out: (addr stream byte), g: grapheme {