diff options
Diffstat (limited to '504test-screen.mu')
-rw-r--r-- | 504test-screen.mu | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/504test-screen.mu b/504test-screen.mu index 64b378dd..f6bdae3b 100644 --- a/504test-screen.mu +++ b/504test-screen.mu @@ -12,7 +12,7 @@ fn check-screen-row-from _screen: (addr screen), x: int, y: int, expected: (addr var screen/esi: (addr screen) <- copy _screen var failure-count/edi: int <- copy 0 var index/ecx: int <- screen-cell-index screen, x, y - # compare 'expected' with the screen contents starting at 'index', grapheme by grapheme + # compare 'expected' with the screen contents starting at 'index', code-point-utf8 by code-point-utf8 var e: (stream byte 0x100) var e-addr/edx: (addr stream byte) <- address e write e-addr, expected @@ -26,16 +26,16 @@ fn check-screen-row-from _screen: (addr screen), x: int, y: int, expected: (addr break-if-!= var _c/eax: code-point <- screen-code-point-at-index screen, index var c/ebx: code-point <- copy _c - var expected-grapheme/eax: grapheme <- read-grapheme e-addr - var expected-code-point/eax: code-point <- to-code-point expected-grapheme - # compare graphemes - $check-screen-row-from:compare-graphemes: { - # if expected-code-point is space, null grapheme is also ok + var expected-code-point-utf8/eax: code-point-utf8 <- read-code-point-utf8 e-addr + var expected-code-point/eax: code-point <- to-code-point expected-code-point-utf8 + # compare code-point-utf8s + $check-screen-row-from:compare-code-point-utf8s: { + # if expected-code-point is space, null code-point-utf8 is also ok { compare expected-code-point, 0x20 break-if-!= compare c, 0 - break-if-= $check-screen-row-from:compare-graphemes + break-if-= $check-screen-row-from:compare-code-point-utf8s } # if (c == expected-code-point) print "." compare c, expected-code-point @@ -79,7 +79,7 @@ fn check-screen-row-in-color screen: (addr screen), fg: int, y: int, expected: ( fn check-screen-row-in-color-from _screen: (addr screen), fg: int, y: int, x: int, expected: (addr array byte), msg: (addr array byte) { var screen/esi: (addr screen) <- copy _screen var index/ecx: int <- screen-cell-index screen, x, y - # compare 'expected' with the screen contents starting at 'index', grapheme by grapheme + # compare 'expected' with the screen contents starting at 'index', code-point-utf8 by code-point-utf8 var e: (stream byte 0x100) var e-addr/edx: (addr stream byte) <- address e write e-addr, expected @@ -93,11 +93,11 @@ fn check-screen-row-in-color-from _screen: (addr screen), fg: int, y: int, x: in break-if-!= var _c/eax: code-point <- screen-code-point-at-index screen, index var c/ebx: code-point <- copy _c - var expected-grapheme/eax: grapheme <- read-grapheme e-addr - var _expected-code-point/eax: code-point <- to-code-point expected-grapheme + var expected-code-point-utf8/eax: code-point-utf8 <- read-code-point-utf8 e-addr + var _expected-code-point/eax: code-point <- to-code-point expected-code-point-utf8 var expected-code-point/edi: code-point <- copy _expected-code-point $check-screen-row-in-color-from:compare-cells: { - # if expected-code-point is space, null grapheme is also ok + # if expected-code-point is space, null code-point-utf8 is also ok { compare expected-code-point, 0x20 break-if-!= @@ -112,14 +112,14 @@ fn check-screen-row-in-color-from _screen: (addr screen), fg: int, y: int, x: in compare color, fg break-if-!= $check-screen-row-in-color-from:compare-cells } - # compare graphemes - $check-screen-row-in-color-from:compare-graphemes: { + # compare code-point-utf8s + $check-screen-row-in-color-from:compare-code-point-utf8s: { # if (c == expected-code-point) print "." compare c, expected-code-point { break-if-!= draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ".", 3/fg=cyan, 0/bg - break $check-screen-row-in-color-from:compare-graphemes + break $check-screen-row-in-color-from:compare-code-point-utf8s } # otherwise print an error count-test-failure @@ -173,7 +173,7 @@ fn check-screen-row-in-background-color screen: (addr screen), bg: int, y: int, fn check-screen-row-in-background-color-from _screen: (addr screen), bg: int, y: int, x: int, expected: (addr array byte), msg: (addr array byte) { var screen/esi: (addr screen) <- copy _screen var index/ecx: int <- screen-cell-index screen, x, y - # compare 'expected' with the screen contents starting at 'index', grapheme by grapheme + # compare 'expected' with the screen contents starting at 'index', code-point-utf8 by code-point-utf8 var e: (stream byte 0x100) var e-addr/edx: (addr stream byte) <- address e write e-addr, expected @@ -187,11 +187,11 @@ fn check-screen-row-in-background-color-from _screen: (addr screen), bg: int, y: break-if-!= var _g/eax: code-point <- screen-code-point-at-index screen, index var g/ebx: code-point <- copy _g - var expected-grapheme/eax: grapheme <- read-grapheme e-addr - var _expected-code-point/eax: code-point <- to-code-point expected-grapheme + var expected-code-point-utf8/eax: code-point-utf8 <- read-code-point-utf8 e-addr + var _expected-code-point/eax: code-point <- to-code-point expected-code-point-utf8 var expected-code-point/edi: code-point <- copy _expected-code-point $check-screen-row-in-background-color-from:compare-cells: { - # if expected-code-point is space, null grapheme is also ok + # if expected-code-point is space, null code-point-utf8 is also ok { compare expected-code-point, 0x20 break-if-!= @@ -206,14 +206,14 @@ fn check-screen-row-in-background-color-from _screen: (addr screen), bg: int, y: compare background-color, bg break-if-!= $check-screen-row-in-background-color-from:compare-cells } - # compare graphemes - $check-screen-row-in-background-color-from:compare-graphemes: { + # compare code-point-utf8s + $check-screen-row-in-background-color-from:compare-code-point-utf8s: { # if (g == expected-code-point) print "." compare g, expected-code-point { break-if-!= draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ".", 3/fg=cyan, 0/bg - break $check-screen-row-in-background-color-from:compare-graphemes + break $check-screen-row-in-background-color-from:compare-code-point-utf8s } # otherwise print an error count-test-failure @@ -228,7 +228,7 @@ fn check-screen-row-in-background-color-from _screen: (addr screen), bg: int, y: draw-code-point-at-cursor-over-full-screen 0/screen, g, 3/cyan, 0/bg draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "'", 3/fg=cyan, 0/bg move-cursor-to-left-margin-of-next-line 0/screen - break $check-screen-row-in-background-color-from:compare-graphemes + break $check-screen-row-in-background-color-from:compare-code-point-utf8s } $check-screen-row-in-background-color-from:compare-background-colors: { var background-color/eax: int <- screen-background-color-at-index screen, index @@ -284,8 +284,8 @@ fn check-background-color-in-screen-row-from _screen: (addr screen), bg: int, y: var unused?/eax: boolean <- screen-cell-unused-at-index? screen, index compare unused?, 0/false break-if-!= - var _expected-bit/eax: grapheme <- read-grapheme e-addr - var expected-bit/edi: grapheme <- copy _expected-bit + var _expected-bit/eax: code-point-utf8 <- read-code-point-utf8 e-addr + var expected-bit/edi: code-point-utf8 <- copy _expected-bit $check-background-color-in-screen-row-from:compare-cells: { var background-color/eax: int <- screen-background-color-at-index screen, index # if expected-bit is space, assert that background is NOT bg @@ -336,23 +336,23 @@ fn check-background-color-in-screen-row-from _screen: (addr screen), bg: int, y: draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ".", 3/fg=cyan, 0/bg } -fn test-draw-single-grapheme { +fn test-draw-single-code-point-utf8 { var _screen: screen var screen/esi: (addr screen) <- address _screen initialize-screen screen, 5, 4, 0/no-pixel-graphics var dummy/eax: int <- draw-code-point screen, 0x61/a, 0/x, 0/y, 1/fg, 2/bg - check-screen-row screen, 0/y, "a", "F - test-draw-single-grapheme" # top-left corner of the screen - check-screen-row-in-color screen, 1/fg, 0/y, "a", "F - test-draw-single-grapheme-fg" - check-screen-row-in-background-color screen, 2/bg, 0/y, "a", "F - test-draw-single-grapheme-bg" - check-background-color-in-screen-row screen, 2/bg, 0/y, "x ", "F - test-draw-single-grapheme-bg2" + check-screen-row screen, 0/y, "a", "F - test-draw-single-code-point-utf8" # top-left corner of the screen + check-screen-row-in-color screen, 1/fg, 0/y, "a", "F - test-draw-single-code-point-utf8-fg" + check-screen-row-in-background-color screen, 2/bg, 0/y, "a", "F - test-draw-single-code-point-utf8-bg" + check-background-color-in-screen-row screen, 2/bg, 0/y, "x ", "F - test-draw-single-code-point-utf8-bg2" } -fn test-draw-multiple-graphemes { +fn test-draw-multiple-code-point-utf8s { var _screen: screen var screen/esi: (addr screen) <- address _screen initialize-screen screen, 0x10/rows, 4/cols, 0/no-pixel-graphics draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "Hello, 世界", 1/fg, 2/bg - check-screen-row screen, 0/y, "Hello, 世界", "F - test-draw-multiple-graphemes" - check-screen-row-in-color screen, 1/fg, 0/y, "Hello, 世界", "F - test-draw-multiple-graphemes-fg" - check-background-color-in-screen-row screen, 2/bg, 0/y, "xxxxxxxxx ", "F - test-draw-multiple-graphemes-bg2" + check-screen-row screen, 0/y, "Hello, 世界", "F - test-draw-multiple-code-point-utf8s" + check-screen-row-in-color screen, 1/fg, 0/y, "Hello, 世界", "F - test-draw-multiple-code-point-utf8s-fg" + check-background-color-in-screen-row screen, 2/bg, 0/y, "xxxxxxxxx ", "F - test-draw-multiple-code-point-utf8s-bg2" } |