about summary refs log tree commit diff stats
path: root/arc/.traces/convert-quotes-defer-reply
blob: e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 (plain) (blame)

mment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
# Some primitives for checking the state of fake screen objects.

# validate data on screen regardless of attributes (color, bold, etc.)
# Mu doesn't have multi-line strings, so we provide functions for rows or portions of rows.
# Tab characters (that translate into multiple screen cells) not supported.

fn check-screen-row screen: (addr screen), y: int, expected: (addr array byte), msg: (addr array byte) {
  check-screen-row-from screen, y, 0, expected, msg
}

fn check-screen-row-from screen-on-stack: (addr screen), x: int, y: int, expected: (addr array byte), msg: (addr array byte) {
  var screen/esi: (addr screen) <- copy screen-on-stack
  var idx/ecx: int <- screen-cell-index screen, y, x
  # compare 'expected' with the screen contents starting at 'idx', grapheme by grapheme
  var e: (stream byte 0x100)
  var e-addr/edx: (addr stream byte) <- address e
  write e-addr, expected
  {
    var done?/eax: boolean <- stream-empty? e-addr
    compare done?, 0
    break-if-!=
    var _g/eax: grapheme <- screen-grapheme-at-idx screen, idx
    var g/ebx: grapheme <- copy _g
    var expected-grapheme/eax: grapheme <- read-grapheme e-addr
    # compare graphemes
    $check-screen-row-from:compare-graphemes: {
      # if expected-grapheme is space, null grapheme is also ok
      {
        compare expected-grapheme, 0x20
        break-if-!=
        compare g, 0
        break-if-= $check-screen-row-from:compare-graphemes
      }
      # if (g == expected-grapheme) print "."
      compare g, expected-grapheme
      {
        break-if-!=
        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ".", 3  # 3=cyan
        break $check-screen-row-from:compare-graphemes
      }
      # otherwise print an error
      count-test-failure
      draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, msg, 3  # 3=cyan
      draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ": expected '", 3
      draw-grapheme-at-cursor 0, expected-grapheme, 3
      move-cursor-rightward-and-downward 0, 0, 0x80  # screen-width
      draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, "' at (", 3
      draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0, x, 3
      draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ", ", 3
      draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0, y, 3
      draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ") but observed '", 3
      draw-grapheme-at-cursor 0, g, 3
      move-cursor-rightward-and-downward 0, 0, 0x80  # screen-width
      draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, "'", 3
    }
    idx <- increment
    increment x
    loop
  }
}

# various variants by screen-cell attribute; spaces in the 'expected' data should not match the attribute

fn check-screen-row-in-color screen: (addr screen), fg: int, y: int, expected: (addr array byte), msg: (addr array byte) {
  check-screen-row-in-color-from screen, fg, y, 0, expected, msg
}

fn check-screen-row-in-color-from screen-on-stack: (addr screen), fg: int, y: int, x: int, expected: (addr array byte), msg: (addr array byte) {
  var screen/esi: (addr screen) <- copy screen-on-stack
  var idx/ecx: int <- screen-cell-index screen, y, x
  # compare 'expected' with the screen contents starting at 'idx', grapheme by grapheme
  var e: (stream byte 0x100)
  var e-addr/edx: (addr stream byte) <- address e
  write e-addr, expected
  {
    var done?/eax: boolean <- stream-empty? e-addr
    compare done?, 0
    break-if-!=
    var _g/eax: grapheme <- screen-grapheme-at-idx screen, idx
    var g/ebx: grapheme <- copy _g
    var _expected-grapheme/eax: grapheme <- read-grapheme e-addr
    var expected-grapheme/edi: grapheme <- copy _expected-grapheme
    $check-screen-row-in-color-from:compare-cells: {
      # if expected-grapheme is space, null grapheme is also ok
      {
        compare expected-grapheme, 0x20
        break-if-!=
        compare g, 0
        break-if-= $check-screen-row-in-color-from:compare-cells
      }
      # if expected-grapheme is space, a different color is ok
      {
        compare expected-grapheme, 0x20
        break-if-!=
        var color/eax: int <- screen-color-at-idx screen, idx
        compare color, fg
        break-if-!= $check-screen-row-in-color-from:compare-cells
      }
      # compare graphemes
      $check-screen-row-in-color-from:compare-graphemes: {
        # if (g == expected-grapheme) print "."
        compare g, expected-grapheme
        {
          break-if-!=
          draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ".", 3  # 3=cyan
          break $check-screen-row-in-color-from:compare-graphemes
        }
        # otherwise print an error
        count-test-failure
        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, msg, 3  # 3=cyan
        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ": expected '", 3
        draw-grapheme-at-cursor 0, expected-grapheme, 3
        move-cursor-rightward-and-downward 0, 0, 0x80  # screen-width
        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, "' at (", 3
        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0, x, 3
        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ", ", 3
        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0, y, 3
        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ") but observed '", 3
        draw-grapheme-at-cursor 0, g, 3
        move-cursor-rightward-and-downward 0, 0, 0x80  # screen-width
        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, "'", 3
      }
      $check-screen-row-in-color-from:compare-colors: {
        var color/eax: int <- screen-color-at-idx screen, idx
        compare fg, color
        {
          break-if-!=
          draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ".", 3  # 3=cyan
          break $check-screen-row-in-color-from:compare-colors
        }
        # otherwise print an error
        count-test-failure
        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, msg, 3  # 3=cyan
        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ": expected '", 3
        draw-grapheme-at-cursor 0, expected-grapheme, 3
        move-cursor-rightward-and-downward 0, 0, 0x80  # screen-width
        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, "' at (", 3
        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0, x, 3
        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ", ", 3
        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0, y, 3
        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, ") in color ", 3
        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0, fg, 3
        draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, " but observed color ", 3
        draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0, color, 3
      }
    }
    idx <- increment
    increment x
    loop
  }
}

fn test-draw-single-grapheme {
  var screen-on-stack: screen
  var screen/esi: (addr screen) <- address screen-on-stack
  initialize-screen screen, 5, 4
  var c/eax: grapheme <- copy 0x61  # 'a'
  draw-grapheme screen, c, 0, 0, 1  # color=1
  check-screen-row screen, 0, "a", "F - test-draw-single-grapheme"  # top-left corner of the screen
}

fn test-draw-multiple-graphemes {
  var screen-on-stack: screen
  var screen/esi: (addr screen) <- address screen-on-stack
  initialize-screen screen, 0x10, 4
  draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "Hello, 世界", 1  # color=1
  check-screen-row screen, 0, "Hello, 世界", "F - test-draw-multiple-graphemes"
}