about summary refs log tree commit diff stats
path: root/063array.mu
Commit message (Expand)AuthorAgeFilesLines
* 4134 - 'input' = 'ingredient'Kartik K. Agaram2017-12-031-9/+9
* 3432Kartik K. Agaram2016-09-301-2/+2
* 3429 - standardize Mu scenariosKartik K. Agaram2016-09-281-16/+16
* 3419Kartik K. Agaram2016-09-271-8/+7
* 3418 - some functions contributed by Caleb CouchKartik K. Agaram2016-09-271-0/+141
* 3417Kartik K. Agaram2016-09-271-2/+3
* 3390Kartik K. Agaram2016-09-171-1/+1
* 3386Kartik K. Agaram2016-09-171-3/+3
* 3385Kartik K. Agaram2016-09-171-2/+2
* 3379Kartik K. Agaram2016-09-171-3/+3
* 3377Kartik K. Agaram2016-09-171-2/+2
* 3055Kartik K. Agaram2016-06-131-0/+40
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 */
# Tests for Mu's stream primitives.

fn test-stream {
  # - write an int to a stream, then read it back
  # step 1: initialize
  var s: (stream int 4)
  var s2/ecx: (addr stream int) <- address s
  var tmp/eax: boolean <- stream-empty? s2
  check-true tmp, "F - test-stream/empty?/0"
  tmp <- stream-full? s2
  check-false tmp, "F - test-stream/full?/0"
  # step 2: write to stream
  var x: int
  copy-to x, 0x34
  var x2/edx: (addr int) <- address x
  write-to-stream s2, x2
  tmp <- stream-empty? s2
  check-false tmp, "F - test-stream/empty?/1"
  tmp <- stream-full? s2
  check-false tmp, "F - test-stream/full?/1"
  # step 3: modify the value written (should make no difference)
  copy-to x, 0
  # step 4: read back
  var y: int
  var y2/ebx: (addr int) <- address y
  read-from-stream s2, y2
  tmp <- stream-empty? s2
  check-true tmp, "F - test-stream/empty?/2"
  tmp <- stream-full? s2
  check-false tmp, "F - test-stream/full?/2"
  # we read back what was written
  check-ints-equal y, 0x34, "F - test-stream"
}

fn test-stream-full {
  # write an int to a stream of capacity 1
  var s: (stream int 1)
  var s2/ecx: (addr stream int) <- address s
  var tmp/eax: boolean <- stream-full? s2
  check-false tmp, "F - test-stream-full?/pre"
  var x: int
  var x2/edx: (addr int) <- address x
  write-to-stream s2, x2
  tmp <- stream-full? s2
  check-true tmp, "F - test-stream-full?"
}

fn test-fake-input-buffered-file {
  var foo: (handle buffered-file)
  var foo-ah/eax: (addr handle buffered-file) <- address foo
  populate-buffered-file-containing "abc", foo-ah
  var foo-addr/eax: (addr buffered-file) <- lookup foo
  var s: (stream byte 0x100)
  var result/ecx: (addr stream byte) <- address s
  read-line-buffered foo-addr, result
  check-stream-equal result, "abc", "F - test-fake-input-buffered-file"
}

fn test-fake-output-buffered-file {
  var foo: (handle buffered-file)
  var foo-ah/eax: (addr handle buffered-file) <- address foo
  new-buffered-file foo-ah
  var foo-addr/eax: (addr buffered-file) <- lookup foo
  write-buffered foo-addr, "abc"
  var s: (stream byte 0x100)
  var result/ecx: (addr stream byte) <- address s
  read-line-buffered foo-addr, result
  check-stream-equal result, "abc", "F - test-fake-output-buffered-file"
}