changeset 32149:6e6e99e8a4de

tests for the new VM New files for genneral tests in the directory test/compile: module.mk, bytecode.tst, bytecode_anon_handles.m, bytecode_ans.m, bytecode_assign.m, bytecode_binops.m, bytecode_cdef_use.m, bytecode_cell.m, bytecode_dountil.m, bytecode_end.m, bytecode_errors.m, bytecode_eval_1.m, bytecode_evalin_1.m, bytecode_evalin_2.m, bytecode_for.m, bytecode_global_1.m, bytecode_if.m, bytecode_index_obj.m, bytecode_inputname.m, bytecode_leaks.m, bytecode_matrix.m, bytecode_misc.m, bytecode_multi_assign.m, bytecode_persistant.m, bytecode_range.m, bytecode_return.m, bytecode_struct.m, bytecode_subfuncs.m, bytecode_subsasgn.m, bytecode_switch.m, bytecode_trycatch.m, bytecode_unary.m, bytecode_unwind.m, bytecode_varargin.m, bytecode_varargout.m, bytecode_while.m, bytecode_wordlistcmd.m, cdef_foo.m, inputname_args.m, just_call_handle_with_arg.m, return_isargout.m, shutup_operator_test/@double/display.m, shutup_operator_test/@logical/display.m, shutup_operator_test/bytecode_disp.m, shutup_operator_test/bytecode_disp.tst, wrongname_fn.m. Microbenchmarks for VM developement in the directory test/compile-bench: module.mk, bench-octave/bench.m, bench-octave/bench_cov.m, bench-octave/bench_median.m, bench-octave/do_until_loop_empty.m, bench-octave/for_loop_binop_1.m, bench-octave/for_loop_empty.m, bench-octave/for_loop_fncall.m, bench-octave/for_loop_ifs.m, bench-octave/for_loop_matselfmul.m, bench-octave/for_loop_silly.m, bench-octave/for_loop_sinpi.m, bench-octave/for_loop_subfun_1.m, bench-octave/for_sum_1.m, bench-octave/for_sum_2.m, bench-octave/qsort_iterative.m, bench-octave/qsort_recursive.m, bench-octave/str_mod.m, bench-octave/while_loop_empty.m, bench-py3/bench.py. * test/Makefile.am: Update.
author Petter T. <petter.vilhelm@gmail.com>
date Mon, 19 Jun 2023 16:35:32 -0400
parents dea87a95ad18
children 994b527e0ffe
files test/Makefile.am test/compile-bench/bench-octave/bench.m test/compile-bench/bench-octave/bench_cov.m test/compile-bench/bench-octave/bench_median.m test/compile-bench/bench-octave/do_until_loop_empty.m test/compile-bench/bench-octave/for_loop_binop_1.m test/compile-bench/bench-octave/for_loop_empty.m test/compile-bench/bench-octave/for_loop_fncall.m test/compile-bench/bench-octave/for_loop_ifs.m test/compile-bench/bench-octave/for_loop_matselfmul.m test/compile-bench/bench-octave/for_loop_silly.m test/compile-bench/bench-octave/for_loop_sinpi.m test/compile-bench/bench-octave/for_loop_subfun_1.m test/compile-bench/bench-octave/for_sum_1.m test/compile-bench/bench-octave/for_sum_2.m test/compile-bench/bench-octave/qsort_iterative.m test/compile-bench/bench-octave/qsort_recursive.m test/compile-bench/bench-octave/str_mod.m test/compile-bench/bench-octave/while_loop_empty.m test/compile-bench/bench-py3/bench.py test/compile-bench/module.mk test/compile/bytecode.tst test/compile/bytecode_anon_handles.m test/compile/bytecode_ans.m test/compile/bytecode_assign.m test/compile/bytecode_binops.m test/compile/bytecode_cdef_use.m test/compile/bytecode_cell.m test/compile/bytecode_dountil.m test/compile/bytecode_end.m test/compile/bytecode_errors.m test/compile/bytecode_eval_1.m test/compile/bytecode_evalin_1.m test/compile/bytecode_evalin_2.m test/compile/bytecode_for.m test/compile/bytecode_global_1.m test/compile/bytecode_if.m test/compile/bytecode_index_obj.m test/compile/bytecode_inputname.m test/compile/bytecode_leaks.m test/compile/bytecode_matrix.m test/compile/bytecode_misc.m test/compile/bytecode_multi_assign.m test/compile/bytecode_persistant.m test/compile/bytecode_range.m test/compile/bytecode_return.m test/compile/bytecode_struct.m test/compile/bytecode_subfuncs.m test/compile/bytecode_subsasgn.m test/compile/bytecode_switch.m test/compile/bytecode_trycatch.m test/compile/bytecode_unary.m test/compile/bytecode_unwind.m test/compile/bytecode_varargin.m test/compile/bytecode_varargout.m test/compile/bytecode_while.m test/compile/bytecode_wordlistcmd.m test/compile/cdef_foo.m test/compile/inputname_args.m test/compile/just_call_handle_with_arg.m test/compile/module.mk test/compile/return_isargout.m test/compile/shutup_operator_test/@double/display.m test/compile/shutup_operator_test/@logical/display.m test/compile/shutup_operator_test/bytecode_disp.m test/compile/shutup_operator_test/bytecode_disp.tst test/compile/wrongname_fn.m
diffstat 67 files changed, 4442 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/test/Makefile.am	Mon Apr 24 20:34:39 2023 +0200
+++ b/test/Makefile.am	Mon Jun 19 16:35:32 2023 -0400
@@ -112,6 +112,8 @@
 include classdef-multiple-inheritance/module.mk
 include classes/module.mk
 include colon-op/module.mk
+include compile-bench/module.mk
+include compile/module.mk
 include ctor-vs-method/module.mk
 include fcn-handle/module.mk
 include file-encoding/module.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile-bench/bench-octave/bench.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,172 @@
+function bench (varargin)
+
+  % The tests to run
+  % 
+  % {name, {arg_type, n}, ...}
+  tests = {
+    {"for_loop_empty", {"n", 206824596}, 1, {}},
+    {"for_loop_silly", {"n", 34894840}, 1, {}},
+    {"for_loop_binop_1", {"n", 20300088}, 1, {}},
+    {"for_loop_sinpi", {"n", 12991066}, 1, {}},
+    {"for_loop_ifs", {"n", 5874007}, 1, {}},
+    {"while_loop_empty", {"n", 24237997}, 1, {}},
+    {"do_until_loop_empty", {"n", 27109647}, 1, {}},
+    {"for_loop_subfun_1", {"n", 11930390}, 1, {}},
+    {"for_loop_matselfmul", {"rand sq",150}, 3, {}},
+    {"for_sum_1", {"rand rowvec", 19267692}, 1, {}},
+    {"for_sum_2", {"rand rowvec", 8742659}, 1, {}},
+    {"qsort_recursive", {"rand rowvec", 107851}, 1, {}}, % Mostly copies vectors around
+    {"qsort_iterative", {"rand rowvec", 344418}, 1, {}},
+    {"for_loop_fncall", {"n", 2164885}, 1, {}},
+    {"bench_median", {"rand rowvec", 1927}, 1, {}},
+    {"bench_cov", {"rand rowvec", 15261}, 1, {}},
+    {"str_mod", {"n", 2335290}, 1, {}},
+  };
+
+  reg = '';
+  calibrate = 0;
+  do_both = 1;
+  n_factor = 1;
+  filter = "";
+  i = 1;
+  while i <= nargin
+    arg = varargin{i++};
+    if strcmp (arg, "reg")
+      assert (i <= nargin)
+      reg = varargin{i++};
+    elseif strcmp (arg, "calibrate")
+      calibrate = 1;
+    elseif strcmp (arg, "n_factor")
+      assert (i <= nargin)
+      n_factor = varargin{i++};
+    end
+  end
+
+  % For compatibility with older releases and Matlab
+  if ~exist("__compile")
+    __compile = @(varargin) true;
+  end
+  if ~exist("__dummy_mark_1")
+    __dummy_mark_1 = @() true;
+  end
+  if ~exist("__dummy_mark_2")
+    __dummy_mark_2 = @() true;
+  end
+
+  cal_res = {};
+
+  for i = 1:length(tests)
+
+    test = tests{i};
+    name = test{1};
+    complexity = test{3};
+    also_compile = test{4};
+    j = 1;
+
+    % Skip on not matching regex, if there is one
+    if length (reg) && isempty (regexp (name, reg))
+      continue;
+    end
+
+    fn = str2func (name);
+
+    printf ("%s:\n", name);
+
+    n = 0;
+    arg = 0;
+    conf = test{2};
+    conf_type = conf {1}; %"n", "rand sq" etc
+    n_norm = conf{2};
+
+    if strcmp (conf_type, "n")
+      n = round (conf{2} * n_factor);
+      arg = n;
+    elseif strcmp (conf_type, "rand sq")
+      rng (0); % Reset rng
+      n = round (conf{2} * n_factor);
+      arg = randn (n);
+    elseif strcmp (conf_type, "rand rowvec")
+      rng (0); % Reset rng
+      n = round (conf{2} * n_factor);
+      arg = randn (n, 1);
+    end
+    n = round (n);
+
+    iters = 1:1;
+    if calibrate
+      iters = 1:40;
+      e_i = 0;
+    end
+
+    for j = iters
+
+      if strcmp (conf_type, "n")
+        n = round (n_norm * n_factor);
+        arg = n;
+      elseif strcmp (conf_type, "rand sq")
+        rng (0); % Reset rng
+        n = round (n_norm * n_factor);
+        arg = randn (n);
+      elseif strcmp (conf_type, "rand rowvec")
+        rng (0); % Reset rng
+        n = round (n_norm * n_factor);
+        arg = randn (n, 1);
+      end
+      n = round (n);
+
+
+      tic;
+      [ccttot0, cctuser0, cctsys0] = cputime;
+      assert (__compile (name));
+      [ccttot1, cctuser1, cctsys1] = cputime;
+      cctwall = toc;
+
+      [cttot0, ctuser0, ctsys0] = cputime;
+      tic;
+      __dummy_mark_1 ();
+      fn (arg);
+      __dummy_mark_2 ();
+      [cttot1, ctuser1, ctsys1] = cputime;
+      ctwall = toc;
+
+      printf ("                %-16s %-16s %-16s %-16s %-16s\n", "t tic","t cpu", "t usr" , "t sys", "n");
+      printf ("    Runtime:    %-16g %-16g %-16g %-16g %-16g\n", ctwall, cttot1 - cttot0, ctuser1 - ctuser0, ctsys1 - ctsys0, n);
+      printf ("    Compiletime %-16g %-16g %-16g %-16g\n\n", cctwall, ccttot1 - ccttot0, cctuser1 - cctuser0, cctsys1 - cctsys0);
+
+      if calibrate
+        t_target = 1;
+        e = ctwall - t_target;
+        if e > 0.5
+          e = 0.5;
+        elseif e < -0.5
+          e = -0.5;
+        end
+
+        n_norm_new = n_norm * (1 - e);
+        if j > 30
+          n_norm = 0.998 * n_norm + 0.002 * n_norm_new;
+        elseif j > 20
+          n_norm = 0.99 * n_norm + 0.01 * n_norm_new;
+        elseif j > 10
+          n_norm = 0.95 * n_norm + 0.05 * n_norm_new;
+        else
+          n_norm = n_norm_new;
+        end
+
+        printf ("    n = %g, e = %g, e_i = %g\n", n_norm, e, e_i);
+      end
+    end
+
+    if calibrate
+      printf ("    Calibrated n: %d\n\n", n);
+      cal_res{end + 1} = {name, n};
+    end
+  end
+
+  if calibrate
+    printf ("Calibrated n:s for 1s\n\n");
+    for e = cal_res
+      printf ("%s %d\n", e{1}{1}, e{1}{2});
+    end
+  end
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile-bench/bench-octave/bench_cov.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,5 @@
+function bench_cov (v)
+  for i = 1:10000
+    cov (v, v);
+  end
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile-bench/bench-octave/bench_median.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,5 @@
+function bench_median (v)
+  for i = 1:10000
+    median (v);
+  end
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile-bench/bench-octave/do_until_loop_empty.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,7 @@
+function do_until_loop_empty (n)
+  i = 0;
+  do
+    i++;
+  until i >= n
+end
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile-bench/bench-octave/for_loop_binop_1.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,6 @@
+function for_loop_binop_1 (n)
+  for i = 1:n
+    j = 1*2*3*4;
+  end
+end
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile-bench/bench-octave/for_loop_empty.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,5 @@
+function for_loop_empty (n)
+  for i = 1:n
+  end
+end
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile-bench/bench-octave/for_loop_fncall.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,5 @@
+function for_loop_fncall (n)
+  for i = 1:n
+    max (i, 2);
+  end
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile-bench/bench-octave/for_loop_ifs.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,30 @@
+function for_loop_ifs (n)
+  for i = 1:n
+    if i == 100
+      continue;
+    elseif i == 300
+      continue;
+    end
+
+    if i * 2 == 3002
+      continue;
+    end
+
+    if i < 0
+      break;
+    end
+
+    if i == -1024
+      disp ("foooo");
+    end
+
+    if i == n + 1
+      break;
+    end
+
+    if ~i
+      break;
+    end
+  end
+end
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile-bench/bench-octave/for_loop_matselfmul.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,18 @@
+function A = for_loop_matselfmul (sq)
+  A = zeros (size (sq));
+
+  cols = size (sq, 2);
+  rows = size (sq, 1);
+
+  assert (cols == rows);
+
+  n = cols;
+
+  for i=1:n
+    for j=1:n
+      for k=1:n
+        A(i,j) = A(i,j)+sq(i,k)*sq(k,j);
+      end
+    end
+  end
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile-bench/bench-octave/for_loop_silly.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,6 @@
+function for_loop_silly (n)
+  for i = 1:n
+    j = i;
+  end
+end
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile-bench/bench-octave/for_loop_sinpi.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,5 @@
+function for_loop_sinpi (n)
+  for i = 1:n
+    j = sin (pi * i);
+  end
+end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile-bench/bench-octave/for_loop_subfun_1.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,9 @@
+function for_loop_subfun_1 (n)
+
+  for i = 1:n
+    suby ();
+  end
+end
+
+function suby ()
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile-bench/bench-octave/for_sum_1.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,7 @@
+function for_sum_1 (mat)
+  sum = 0;
+  for i = 1:length (mat)
+    sum = sum + mat (i);
+  end
+end
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile-bench/bench-octave/for_sum_2.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,7 @@
+function sum = for_sum_2 (arg)
+  sum = 0;
+  for i = arg'
+    sum = sum + i;
+  end
+end
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile-bench/bench-octave/qsort_iterative.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,48 @@
+function A = qsort_iterative (A)
+  len = length (A);
+  stack = zeros (64, 1);
+
+  top = 0;
+
+  % Push initial indices to the stack
+  stack (++top) = 1;
+  stack (++top) = len;
+
+  while top > 0
+    % Pop indices
+    high = stack (top--);
+    low = stack (top--);
+
+    % Partion part of the algorithm
+    p = low - 1; % pivot index
+    x = A (high);% pivot value
+
+    % Swap so that there are two parts. One less than or equal to the pivot
+    % value and one higher
+    for j = low:high - 1
+      if A(j) <= x
+        p++;
+        tmp = A(j);
+        A(j) = A(p);
+        A(p) = tmp;
+      end
+    end
+    % Swap the pivot value with the first value bigger than the pivot
+    p++;
+    tmp = A(high);
+    A(high) = A(p);
+    A(p) = tmp;
+    % End partion
+
+    % Push left and right indices (if there are any value to the left or right)
+    if p - 1 > low
+      stack(++top) = low;
+      stack(++top) = p - 1;
+    end
+
+    if p + 1 < high
+      stack(++top) = p + 1;
+      stack(++top) = high;
+    end
+  end
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile-bench/bench-octave/qsort_recursive.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,36 @@
+% Most time is spent copying vectors anyway so terrible test really.
+
+function A = qsort_recursive (A)
+  if isempty (A) || length(A) == 1
+    return;
+  end
+
+  [p, A] = partion (A);
+
+  left = qsort_recursive (A(1:p - 1));
+  right = qsort_recursive (A(p + 1:end));
+
+  A = [left A(p) right];
+end
+
+function [p, A] = partion (A)
+  lo = 1;
+  hi = length (A);
+
+  pivot = A(hi);
+
+  p = lo - 1;
+
+  for j = lo:1:hi-1
+    if A(j) <= pivot
+      p++;
+      tmp = A(j);
+      A (j) = A (p);
+      A (p) = tmp;
+    end
+  end
+  p++;
+  tmp = A(hi);
+  A(hi) = A(p);
+  A(p) = tmp;
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile-bench/bench-octave/str_mod.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,9 @@
+function str_mod (n)
+
+  s1 = "qweasd";
+  s2 = "zxccvb";
+  for i = 1:n
+    s1 (2) = "f";
+    s2 (1) = s1(3);
+  end
+end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile-bench/bench-octave/while_loop_empty.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,7 @@
+function while_loop_empty (n)
+  i = 0;
+  while i < n
+    i++;
+  end
+end
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile-bench/bench-py3/bench.py	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,142 @@
+#!/usr/bin/env python3
+
+from timeit import default_timer as timer
+from array import *
+import random
+import math
+
+def for_loop_empty (n):
+    for i in range (1, n + 1):
+        continue
+
+def for_loop_silly (n):
+    for i in range (1, n + 1):
+        j = i
+
+def for_loop_binop_1(n):
+    for i in range (1, n + 1):
+        j = 1*2*3*4
+
+def for_loop_sinpi (n):
+    for i in range (1, n):
+        j = math.sin (math.pi * i)
+
+def for_loop_ifs (n):
+    for i in range (1, n + 1):
+        if i == 100.0:
+            continue
+        elif i == 300.0:
+            continue
+
+        if i * 2.0 == 3002.0:
+            continue
+
+        if i < 0.0:
+            break
+
+        if i == -1024.0:
+            print ("fooo")
+
+        if i == n + 1.0:
+            break
+
+        if not i:
+            break
+
+def while_loop_empty (n):
+    i = 0.0
+    while i < n:
+        i += 1
+
+def for_loop_subfun_1 (n):
+    for i in range (n):
+        suby ()
+
+def suby ():
+    return
+
+def qsort_iterative (A):
+    l = len (A)
+    stack = [0] * 128 # Probably big enough
+
+    top = 0
+    stack[top] = 0
+    top += 1
+    stack[top] = l - 1
+    top += 1
+
+    while top > 0:
+        top -= 1
+        high = stack[top]
+        top -= 1
+        low = stack[top]
+
+        p = low - 1
+        x = A[high]
+
+        for j in range (low, high):
+            if A[j] <= x:
+                p += 1
+                tmp = A[j]
+                A[j] = A[p]
+                A[p] = tmp
+        p += 1
+        tmp = A[high]
+        A[high] = A[p]
+        A[p] = tmp
+
+        if p - 1 > low:
+            stack[top] = low
+            top += 1
+            stack[top] = p - 1
+            top += 1
+        if p + 1 < high:
+            stack[top] = p + 1
+            top += 1
+            stack[top] = high
+            top += 1
+
+    return A
+
+def time_fn_call (fn, arg):
+    start = timer()
+    fn (arg)
+    end = timer()
+
+    return end - start
+
+def randn (rows, cols):
+    if rows == 1:
+        arr = array('d')
+        for i in range(cols):
+            arr.append(random.gauss (0, 1))
+        return arr
+    
+    arr = array()
+    for i in range (rows):
+        arr_row = array('d')
+        for j in range(cols):
+          arr_row.append(random.gauss (0, 1))
+        arr.append (arr_row)
+    return arr
+
+tests = \
+   [[for_loop_empty, 206824596],
+    [for_loop_silly, 34894840],
+    [for_loop_binop_1, 20300088],
+    [for_loop_sinpi, 12991066],
+    [for_loop_ifs, 5874007],
+    [while_loop_empty, 24237997],
+    [for_loop_subfun_1, 11930390],
+    [qsort_iterative, "rowvec", 344418]]
+
+def main():
+    for t in tests:
+        if (t[1] == "rowvec"):
+            dt = time_fn_call (t[0], randn (1, t[2]))
+        else:
+            dt = time_fn_call (t[0], t[1])
+        print (t[0].__name__ + " in %g s" % dt)
+
+if __name__ == "__main__":
+    main ()    
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile-bench/module.mk	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,22 @@
+compile_bench_TEST_FILES = \
+  %reldir%/compile-bench/bench-octave/bench.m \
+  %reldir%/compile-bench/bench-octave/bench_cov.m\
+  %reldir%/compile-bench/bench-octave/bench_median.m\
+  %reldir%/compile-bench/bench-octave/do_until_loop_empty.m\
+  %reldir%/compile-bench/bench-octave/for_loop_binop_1.m\
+  %reldir%/compile-bench/bench-octave/for_loop_empty.m\
+  %reldir%/compile-bench/bench-octave/for_loop_fncall.m\
+  %reldir%/compile-bench/bench-octave/for_loop_ifs.m\
+  %reldir%/compile-bench/bench-octave/for_loop_matselfmul.m\
+  %reldir%/compile-bench/bench-octave/for_loop_silly.m\
+  %reldir%/compile-bench/bench-octave/for_loop_sinpi.m\
+  %reldir%/compile-bench/bench-octave/for_loop_subfun_1.m\
+  %reldir%/compile-bench/bench-octave/for_sum_1.m\
+  %reldir%/compile-bench/bench-octave/for_sum_2.m\
+  %reldir%/compile-bench/bench-octave/qsort_iterative.m\
+  %reldir%/compile-bench/bench-octave/qsort_recursive.m\
+  %reldir%/compile-bench/bench-octave/str_mod.m\
+  %reldir%/compile-bench/bench-octave/while_loop_empty.m\
+  %reldir%/compile-bench/bench-py3/bench.py
+
+TEST_FILES += $(compile_bench_TEST_FILES)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode.tst	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,664 @@
+########################################################################
+##
+## Copyright (C) 2006-2022 The Octave Project Developers
+##
+## See the file COPYRIGHT.md in the top-level directory of this
+## distribution or <https://octave.org/copyright/>.
+##
+## This file is part of Octave.
+##
+## Octave is free software: you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <https://www.gnu.org/Test/>.
+##
+########################################################################
+
+## Just clear the cached string in __prog_output_assert__() and clear 
+## classes method lookups due to maybe bug
+%!test
+%! __prog_output_assert__ ("");
+%! % Overloading of class-methods seems to stick so we need to clear them since we overload
+%! % double's display. Is this a bug ???
+%! clear classes
+
+## licenses binary expression
+%!test
+%! __enable_vm_eval__ (0, "local"); % Disable the vm for the tree_walker run
+%!
+%! clear all % We want all compiled functions to be cleared so that we can run the tree_walker
+%!
+%! key = "10 -10 24 0.041666666666666664 1 -5.0915810909090906 13 1 0 1 0 truthy1 1 falsy3 falsy4 truthy5 1 truthy7 truthy8 1 falsy9 falsy11 0 1 0 1 0 0 1 1 0 1 0 1 1 1 0 1 0 1 0 0 0 0 1 1 1 1 1 1 1 1 ";
+%!
+%! __compile bytecode_binops clear;
+%! bytecode_binops ();
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! % We wanna know the function compiles, so do a explicit compile
+%! assert (__compile ("bytecode_binops"));
+%! bytecode_binops ();
+%! assert (__prog_output_assert__ (key));
+
+## Test subfunctions
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "2 2 2 11 30 10 30 5  0 0 double 1 2 1 2 double 30 11 5  0 0 double 1 2 1 2 double 11 11 12 13 1 1 double 14 1 1 double 11 11 5 13 1 1 double 14 1 1 double 11 3 3 3 2 2 2 313 ret32:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 ret32:1 ret32:ret32:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 take32:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 1 18 59 64 ";
+%! a = 313;
+%! % Gets called to ensure anonymous functions calls with 
+%! % externally scoped variables work
+%! h = @() __printf_assert__ ("%d ", a);
+%!
+%! __compile bytecode_subfuncs clear;
+%! bytecode_subfuncs (h);
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_subfuncs"));
+%! bytecode_subfuncs (h);
+%! assert (__prog_output_assert__ (key));
+
+## Test if:s
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "0 1 2 3 4 5 6 7 8 1 2 yay1 3 5 7 8 1 yay1 3 4 yay2 5 6 7 yay3 ";
+%!
+%! __compile bytecode_if clear;
+%! bytecode_if ();
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_if"));
+%! bytecode_if ();
+%! assert (__prog_output_assert__ (key));
+
+## Test for:s
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "1 2 3 4 4 1 3 5 5 4 3 2 1 1 1 4 2 2 16 4 3 3 256 3 2 1  double 1 3 size 2 size 1 2 4 size 2 size 1  double q size 1 size 1 w size 1 size 1 e size 1 size 1 char single single 5 1 11 2 12 key:a val:1 1val:1 key:b val:1 3val:2 4val:2 2key:c val:string ";
+%!
+%! __compile bytecode_for clear;
+%! bytecode_for ();
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_for"));
+%! bytecode_for ();
+%! assert (__prog_output_assert__ (key));
+
+## Test while
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "5 4 3 2 1 3 5 4 4 3 3 4 1 2 1 3 2 8 3 1 3 ";
+%!
+%! __compile bytecode_while clear;
+%! bytecode_while ();
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_while"));
+%! bytecode_while ();
+%! assert (__prog_output_assert__ (key));
+
+## Test assign
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "2 3 1 1 2 3 2 3 2 2 6 18 2.000000 2.000000 3.000000 4.000000 5.000000 1 4 double 729.000000 324.000000 182.250000 116.640000 4 1 double 37.000000 81.000000 54.000000 118.000000 2 2 double ";
+%!
+%! __compile bytecode_assign clear;
+%! bytecode_assign ();
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_assign"));
+%! bytecode_assign ();
+%! assert (__prog_output_assert__ (key));
+
+## Test unary
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "-1 4 1 2 3 4 1 3 2 4 0 0 ";
+%!
+%! __compile bytecode_unary clear;
+%! bytecode_unary ();
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_unary"));
+%! bytecode_unary ();
+%! assert (__prog_output_assert__ (key));
+
+## Test range
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "1 2 3 1 3 5 1 3 5 1 1.1 1.2 1.3 1.4 1 0.9 0.8 0.7 7 7 1 8 10 8 10 8 9 10 11 8 9 10 11 10 8 10 8 -10 -9 -8 -7 -10 -9 -8 -7 ";
+%!
+%! __compile bytecode_range clear;
+%! bytecode_range ();
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_range"));
+%! bytecode_range ();
+%! assert (__prog_output_assert__ (key));
+
+## Test multi assign
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "3 4 2 2 1 2 3 4 1 2 3 4 1 1 3 2 3 4 1 1 1 2 3 4 1 1 1 2 3 4 1 2 3 ";
+%!
+%! __compile bytecode_multi_assign clear;
+%! bytecode_multi_assign ();
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_multi_assign"));
+%! bytecode_multi_assign ();
+%! assert (__prog_output_assert__ (key));
+
+## Test subsasgn
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! clear functions  % persistent variables in bytecode_subsasgn
+%! key = "3 5 9 8 11 13 1 2 3 4 5 6 77 88 99 1010 1 2 3 987 987 6 77 88 99 1010 0 0 0 0 0 13 double 3 2 4 2 3 cell 1 3 6 7 2 3 1 4 5 1 3 5 2 4 6 7 7 7 7 7 7 1 2 3 1 3 3 2 3 2 3 1 3 1 2 3 4 4 4 3 4 5 6 1 5 3 4 1 5 -1 4 1 5 -1 8 ";
+%!
+%! __compile bytecode_subsasgn clear;
+%! bytecode_subsasgn ();
+%! assert (__prog_output_assert__ (key), "bytecode_subsasgn failed uncompiled");
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_subsasgn"));
+%! bytecode_subsasgn ();
+%! assert (__prog_output_assert__ (key), "bytecode_subsasgn failed compiled");
+
+## Test end
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "1 3 2 4 1 5 6 7 2 2 5 5 6 6 1 2 3 4 5 2 2 2 3 3 4 fs 2 3 1 foo oo ";
+%!
+%! __compile bytecode_end clear;
+%! bytecode_end ();
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_end"));
+%! bytecode_end ();
+%! assert (__prog_output_assert__ (key));
+
+## Test matrix
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "1 2 3 4 1 4 1 2 3 4 4 1 1 3 2 4 2 2 1 3 1 3 2 4 2 4 4 2  0 0 a b c d 7 15 10 22 2 2 30 1 1 1 2 3 4 2 4 6 8 3 6 9 12 4 8 12 16 4 4 1 1 1 0.0333333 0.0666667 0.1 0.133333 0.0666667 0.133333 0.2 0.266667 0.1 0.2 0.3 0.4 0.133333 0.266667 0.4 0.533333 4 4 1 0 0 1 2 2 30 1 1 10 14 14 20 2 2 0.0333333 0.0666667 0.1 0.133333 0.0666667 0.133333 0.2 0.266667 0.1 0.2 0.3 0.4 0.133333 0.266667 0.4 0.533333 4 4 2.5 -0.5 2 0 2 2 2 6 4 8 2 2 2 3 4 5 3 4 5 6 4 5 6 7 5 6 7 8 4 4 3 4 5 6 1 4 3 4 5 6 1 4 -1 0 1 2 1 4 2 4 6 8 1 4 0.5 1 1.5 2 1 4 0.5 1 1.5 2 1 4 1 4 9 16 1 4 1 1 1 1 1 4 1 1 1 1 1 4 1 4 27 256 1 4 1 2 3 4 2 4 6 8 3 6 9 12 4 8 12 16 4 4 1 0.5 0.333333 0.25 2 1 0.666667 0.5 3 1.5 1 0.75 4 2 1.33333 1 4 4 1 2 3 4 0.5 1 1.5 2 0.333333 0.666667 1 1.33333 0.25 0.5 0.75 1 4 4 1 4 27 256 4 1 qzwxeca s d  zzxxccz x c  1 258 33264 258 1 33264 ";
+%!
+%! __compile bytecode_matrix clear;
+%! bytecode_matrix ();
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_matrix"));
+%! bytecode_matrix ();
+%! assert (__prog_output_assert__ (key));
+
+## Test return
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "2 baaar bääär baaaaz bääääz bääääz booz 1 1 2 1 1 1 2 1 silly silly ";
+%!
+%! __compile bytecode_return clear;
+%! bytecode_return ();
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_return"));
+%! bytecode_return ();
+%! assert (__prog_output_assert__ (key));
+
+## Test word list command
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "A B C QWE ";
+%!
+%! __compile bytecode_wordlistcmd clear;
+%! bytecode_wordlistcmd ();
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_wordlistcmd"));
+%! bytecode_wordlistcmd ();
+%! assert (__prog_output_assert__ (key));
+
+## Test do until
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "5 3 5 5 4 4 3 4 1 2 1 3 2 12 3 0 3 ";
+%!
+%! __compile bytecode_dountil clear;
+%! bytecode_dountil ();
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_dountil"));
+%! bytecode_dountil ();
+%! assert (__prog_output_assert__ (key));
+
+## Test cell
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "a b a b 1 2 b c b c 1 2 char b c c d b d c e 2 2 b d f h j l c e g i k m 6 2 1 2 2 3 1 3 2 4 1 3 1 2 1 3 2 4 2 2 double qwe 1 3 char 1 2 ";
+%!
+%! __compile bytecode_cell clear;
+%! bytecode_cell ();
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_cell"));
+%! bytecode_cell ();
+%! assert (__prog_output_assert__ (key));
+
+## Test varargin
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "2 3 1 2 1 1 1 1 1 2 3 4 1 4 4 0 0 0 1 2 3 4 1 3 4 2 3 4 1 3 3 2 2 3 4 1 4 4 1 0 0 1 0 0 0 2 1 1 1 1 2 3 4 1 3 4 2 3 4 1 3 3 2 2 3 4 1 4 4 2 1 2 4 1 2 3 4 3 3 2 1 0 ";
+%!
+%! __compile bytecode_varargin clear;
+%! bytecode_varargin (1,2,3);
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_varargin"));
+%! bytecode_varargin (1,2,3);
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "0 0 1 1 1 1 1 2 3 4 1 4 4 0 0 0 1 2 3 4 1 3 4 2 3 4 1 3 3 2 2 3 4 1 4 4 1 0 0 1 0 0 0 2 1 1 1 1 2 3 4 1 3 4 2 3 4 1 3 3 2 2 3 4 1 4 4 2 1 2 4 1 2 3 4 1 3 2 1 0 ";
+%!
+%! __compile bytecode_varargin clear;
+%! bytecode_varargin (1);
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_varargin"));
+%! bytecode_varargin (1);
+%! assert (__prog_output_assert__ (key));
+
+## Test global variables
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "double 0 0 1 1 1 1 1 2 2 2 400 100 0 1 3 double 1 1 1 2 double 1 2 1 1 11 eclass:double 1 1 3 4 double 1 2 400 100 1 1 1 1 3 4 1 1 5 6 1 1 1 2 double 1 2 1 2 double 1 2 1 1 3 4 eclass:double 1 2 3 4 double 1 2 0 0 1 1 3 4 1 1 5 6 1 0 2 double 2 double 11 2 6 4 5 double 1 5 11 double 1 1 22 double 1 1 33 double 1 1 3 double 1 1 4 double 1 1 10 double 1 1 2 3 double 1 2 3 double 1 1 2 double 1 1 55 double 1 1 7 double 1 1 0 ";
+%!
+%! __compile bytecode_global_1 clear;
+%! clear global a;
+%! clear global b;
+%! clear global q
+%! global q % Used in test function
+%! q = 55;
+%! bytecode_global_1 ();
+%! assert (__prog_output_assert__ (key));
+%! assert (length(who('global','a')));
+%! assert (length(who('global','b')));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_global_1"));
+%! clear global a;
+%! clear global b;
+%! clear global q;
+%! global q % Used in test function
+%! q = 55;
+%! bytecode_global_1 ();
+%! assert (length(who('global','a')));
+%! assert (length(who('global','b')));
+%! assert (__prog_output_assert__ (key));
+%!
+%! global a b;
+%! assert (a == 5);
+%! assert (b == 6);
+%!
+%! clear global a;
+%! clear global b;
+%! clear global q;
+
+## Test switch
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "yay yay2 yay3 yay4 yay5 yay6 yay7 yay8 1 2 3 3 1 3 3 4 4 1 3 3 4 4 2 yoo 2 3 3 1:1 for-end:12:2 3:3 for-end:3breaking:4 ";
+%!
+%! __compile bytecode_switch clear;
+%! bytecode_switch;
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_switch"));
+%! bytecode_switch;
+%! assert (__prog_output_assert__ (key));
+
+## Test eval (dynamic stack frames)
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "3.000000 1.000000 1.000000 double 4.000000 1.000000 1.000000 double 4.000000 1.000000 1.000000 double 5.000000 4.000000 2.000000 3.000000 1.000000 1.000000 double 4.000000 1.000000 1.000000 double 4.000000 1.000000 1.000000 double 5.000000 4.000000 2.000000 1:11.000000 2:22.000000 3:33.000000 4:3.000000 5:22.000000 6:3.000000 7:3.000000 3 3 2 2 3.000000 3.000000 ";
+%!
+%! __compile bytecode_eval_1 clear;
+%! bytecode_eval_1;
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_eval_1"));
+%! bytecode_eval_1;
+%! assert (__prog_output_assert__ (key));
+
+## Test evalin and assignin
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! % We want to test all combinations of compiled and uncompiled evalin_1 and 2.
+%!
+%! key = "2.000000 yoyo yobase 3.000000 yoyo2 yobase2 123.000000 124.000000 11.000000 33.000000 ";
+%!
+%! caller_a = 2;
+%!
+%!
+%! __compile bytecode_evalin_1 clear;
+%! __compile bytecode_evalin_2 clear;
+%! bytecode_evalin_1 ();
+%! assert (__prog_output_assert__ (key));
+%!
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_evalin_1"));
+%! bytecode_evalin_1 ();
+%! assert (__prog_output_assert__ (key));
+%!
+%!
+%! __compile bytecode_evalin_1 clear;
+%! __compile bytecode_evalin_2 clear;
+%! assert (__compile ("bytecode_evalin_1"));
+%! assert (__compile ("bytecode_evalin_2"));
+%! bytecode_evalin_1 ();
+%! assert (__prog_output_assert__ (key));
+%!
+%! __compile bytecode_evalin_1 clear;
+%! __compile bytecode_evalin_2 clear;
+%! assert (__compile ("bytecode_evalin_2"));
+%! bytecode_evalin_1 ();
+%! assert (__prog_output_assert__ (key));
+%!
+
+## Test error messages
+%!test
+%! ## Interpreter reference
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! __compile bytecode_errors clear;
+%! fail ("bytecode_errors (0)", ...
+%!       "'qweqwe' undefined near line 9, column 6");
+%! fail ("bytecode_errors (1)", ...
+%!       "'b' undefined near line 15, column 7");
+%! fail ("bytecode_errors (2)", ...
+%!       "'b' undefined near line 19, column 7");
+%! fail ("bytecode_errors (3)", ...
+%!       "'b' undefined near line 23, column 7");
+%! fail ("bytecode_errors (4)", ...
+%!       "'b' undefined near line 27, column 3");
+%! fail ("bytecode_errors (5)", ...
+%!       "'b' undefined near line 31, column 3");
+%! fail ("bytecode_errors (6)", ...
+%!       'a\(3\): out of bound 2 \(dimensions are 1x2\)');
+%! fail ("bytecode_errors (7)", ...
+%!       'a\(-1\): subscripts must be either integers 1 to \(2\^63\)-1 or logicals');
+%! fail ("bytecode_errors (8)", ...
+%!       'operator \+: nonconformant arguments \(op1 is 1x3, op2 is 1x2\)');
+%!
+%! __enable_vm_eval__ (1, "local");
+%! ## Bytecode running the same errors
+%! __compile bytecode_errors;
+%! fail ("bytecode_errors (0)", ...
+%!       "'qweqwe' undefined near line 9, column 6");
+%! fail ("bytecode_errors (1)", ...
+%!       "'b' undefined near line 15, column 7");
+%! fail ("bytecode_errors (2)", ...
+%!       "'b' undefined near line 19, column 7");
+%! fail ("bytecode_errors (3)", ...
+%!       "'b' undefined near line 23, column 7");
+%! fail ("bytecode_errors (4)", ...
+%!       "'b' undefined near line 27, column 3");
+%! fail ("bytecode_errors (5)", ...
+%!       "'b' undefined near line 31, column 3");
+%! fail ("bytecode_errors (6)", ...
+%!       'a\(3\): out of bound 2 \(dimensions are 1x2\)');
+%! fail ("bytecode_errors (7)", ...
+%!       'a\(-1\): subscripts must be either integers 1 to \(2\^63\)-1 or logicals');
+%! fail ("bytecode_errors (8)", ...
+%!       'operator \+: nonconformant arguments \(op1 is 1x3, op2 is 1x2\)');
+
+## Test try catch
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "yay yay2 yay3 ooo yay2 yay3 ooo2 ooo2 yay3 yay4 Nested error yay5 yay6 In catch yay7 qwe yay8 Error in subfunction yay9 'asd' undefined near line 87, column 11 yay10 operator *: nonconformant arguments (op1 is 1x2, op2 is 1x3) yay11 yoyo yay12 foo yay12 foo yay12 foo yay13 foo yay13 foo yay13 foo ";
+%!
+%! __compile bytecode_trycatch clear;
+%! bytecode_trycatch;
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_trycatch"));
+%! bytecode_trycatch;
+%! assert (__prog_output_assert__ (key));
+
+## Test unwind protect
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "yay1 yay2 yay3 e1 subyyay1 subyyay2 subyyay3 subyyay4 subyyay5 subyyay6 subyyay7 subyyay8 subyyay9 subyyay10 subyyay11 subyyay12 subyyay13 subyyay14 subyyay15 subyyay16 subyyay17 subyyay18 yay4 yay5 yay6 ";
+%! __compile bytecode_unwind clear;
+%! bytecode_unwind;
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_unwind"));
+%! bytecode_unwind;
+%! assert (__prog_output_assert__ (key));
+
+## Test persistant
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! clear functions  % clear persistent variables in bytecode_persistant
+%! key = "a:3 b: double 0 0 0 c:3 c:4 a:4 b:1 double 1 1 0 c:5 c:6 ";
+%!
+%! __compile bytecode_persistant clear;
+%! bytecode_persistant;
+%! bytecode_persistant;
+%! assert (__prog_output_assert__ (key));
+%!
+%! clear all;
+%! __enable_vm_eval__ (1, "local");
+%! key = "a:3 b: double 0 0 0 c:3 c:4 a:4 b:1 double 1 1 0 c:5 c:6 ";
+%! assert (__compile ("bytecode_persistant"));
+%! bytecode_persistant;
+%! disp ("\n");
+%! bytecode_persistant;
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (0, "local");
+%! __compile bytecode_persistant clear;
+%! clear all;
+%! key = "a:3 b: double 0 0 0 c:3 c:4 a:4 b:1 double 1 1 0 c:5 c:6 ";
+%! bytecode_persistant;
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_persistant"));
+%! disp ("\n");
+%! bytecode_persistant;
+%! assert (__prog_output_assert__ (key));
+
+## Test structs
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "1 2 double 1 1 struct 3 4 ";
+%! __compile bytecode_struct clear;
+%! bytecode_struct;
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_struct"));
+%! bytecode_struct;
+%! assert (__prog_output_assert__ (key));
+
+## Test indexing chained objects and strange indexing
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "2 2 3 3 2 cell 1 1 3 3 2 3 22 double 33 3 4 matlab.lang.MemoizedFunction 2 ";
+%! __compile bytecode_index_obj clear;
+%! bytecode_index_obj;
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_index_obj"));
+%! bytecode_index_obj;
+%! assert (__prog_output_assert__ (key));
+
+## Test varargout
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "7 8 1 1 2 1 0 0 0 1 0 1 0 0 0 1 0 ";
+%! __compile bytecode_varargout clear;
+%! bytecode_varargout;
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_varargout"));
+%! bytecode_varargout;
+%! assert (__prog_output_assert__ (key));
+
+## Test inputname
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "a a b + 1  a a b b aa aa bb bb aa + 1  bb * 3  a + 1  b * 3  aa aa bb bb aa + 1  bb * 3  a a b b a + 1  b * 3  ";
+%! __compile bytecode_inputname clear;
+%! a = 9; b = 8;
+%! bytecode_inputname (a, b + 1);
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_inputname"));
+%! bytecode_inputname (a, b + 1);
+%! assert (__prog_output_assert__ (key));
+
+## Test ans
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "2 5 1 1 1 ";
+%! __compile bytecode_ans clear;
+%! bytecode_ans;
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_ans"));
+%! bytecode_ans;
+%! assert (__prog_output_assert__ (key));
+
+## Test using classdef
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! global cdef_foo_ctor_cnt; clear global cdef_foo_ctor_cnt;
+%! global cdef_foo_dtor_cnt; clear global cdef_foo_dtor_cnt;
+%! key = ". 1 f1 . 2 f3 3 f2 . sumf2f3 2 . . call14 f4 . a a_1 . 5 f8 . 6 f10 7 f9 . sumf9f10 2 . . call18 f11 . 2 2 3 4 4 4 3 2 2 3 . 9 sumf9f10 10 f12 11 f13 12 f14 13 sumf2f3 14 f5 15 f6 16 f7 ";
+%! __compile bytecode_cdef_use clear;
+%! bytecode_cdef_use ();
+%! assert (__prog_output_assert__ (key));
+%! global cdef_foo_ctor_cnt; global cdef_foo_dtor_cnt; 
+%! assert (cdef_foo_ctor_cnt == cdef_foo_dtor_cnt); % Check, as many ctor and dtor executions
+%!
+%! __enable_vm_eval__ (1, "local");
+%! global cdef_foo_ctor_cnt; clear global cdef_foo_ctor_cnt;
+%! global cdef_foo_dtor_cnt; clear global cdef_foo_dtor_cnt;
+%! assert (__compile ("bytecode_cdef_use"));
+%! bytecode_cdef_use ();
+%! assert (__prog_output_assert__ (key));
+%! global cdef_foo_ctor_cnt; global cdef_foo_dtor_cnt; 
+%! assert (cdef_foo_ctor_cnt == cdef_foo_dtor_cnt);
+%!
+%! global cdef_foo_ctor_cnt; clear global cdef_foo_ctor_cnt;
+%! global cdef_foo_dtor_cnt; clear global cdef_foo_dtor_cnt;
+%!
+%! clear global __assert_printf__
+
+## Test anonymous function handles
+%!test
+%! __enable_vm_eval__ (0, "local");
+%! clear all
+%! key = "1 2 12 3 4 1 2 3 1 2 11 12 1 ";
+%! __compile bytecode_anon_handles clear;
+%! bytecode_anon_handles;
+%! assert (__prog_output_assert__ (key));
+%!
+%! __enable_vm_eval__ (1, "local");
+%! assert (__compile ("bytecode_anon_handles"));
+%! bytecode_anon_handles;
+%! assert (__prog_output_assert__ (key));
+
+## Test compling a function named differently from its
+## m-file
+%!test
+%! clear all
+%! __enable_vm_eval__ (1, "local");
+%! __compile wrongname_fn clear;
+%! assert (__compile ("wrongname_fn"));
+%!
+%! assert (wrongname_fn (77) == 78);
+
+## Test some misc stuff
+%!test
+%! clear all
+%! __enable_vm_eval__ (1, "local");
+%!
+%! bytecode_misc; % asserts inernally
+
+## Leak check
+%!test
+%! clear all
+%! __enable_vm_eval__ (1, "local");
+%!
+%! c = 2;
+%! d = 3;
+%! n_c = __ref_count (c);
+%! n_d = __ref_count (d);
+%! bytecode_leaks (c, d); % asserts inernally
+%!
+%! assert (n_c == __ref_count (c))
+%! assert (n_d == __ref_count (d))
+%!
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_anon_handles.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,27 @@
+function bytecode_anon_handles ()
+  h1 = @(x) __printf_assert__ ("%d ", x);
+  h1 (1);
+  h1 (2);
+  h11 = h1;
+  h11 (12);
+
+  a = 3;
+  h2 = @() __printf_assert__ ("%d ", a);
+  h2 ();
+
+  h3 = @(a,b,c) a + b + c;
+  __printf_assert__ ("%d ", h3 (1, 2, 1));
+
+  h4 = @() {1,2,3}{:};
+  [a b c] = h4();
+  __printf_assert__ ("%d %d %d ", a, b, c);
+  [a b] = h4();
+  __printf_assert__ ("%d %d ", a, b);
+  
+  h5 = @(x) @(y) __printf_assert__ ("%d %d ", x, y);
+  h5(11)(12)
+
+  % max not in parent scope
+  h6 = @(x, y) max (x, y);
+  __printf_assert__ ("%d ", h6 (-1, 1));
+end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_ans.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,13 @@
+function bytecode_ans ()
+    max (1, 2);
+    __printf_assert__ ("%d ", ans);
+    1 + 1 + 3;
+    __printf_assert__ ("%d ", ans);
+    !false;
+    __printf_assert__ ("%d ", ans);
+    true;
+    __printf_assert__ ("%d ", ans);
+
+    c = 13; % Not written to ans
+    __printf_assert__ ("%d ", ans);
+end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_assign.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,57 @@
+function bytecode_assign ()
+
+  a = 2;
+  __printf_assert__ ("%d ", a);
+
+  a = 3;
+  __printf_assert__ ("%d ", a);
+
+  b = a = 1;
+  __printf_assert__ ("%d ", a);
+  __printf_assert__ ("%d ", b);
+
+  c = [2 2; 3 3];
+  d = c (1,2);
+  __printf_assert__ ("%d ", c);
+  __printf_assert__ ("%d ", d);
+
+  % Compound assignment
+  d = 1;
+  d += 1;
+  __printf_assert__ ("%d ", d);
+  d += d * 2;
+  __printf_assert__ ("%d ", d);
+  d *= 3;
+  __printf_assert__ ("%d ", d);
+  d /= 9;
+  __printf_assert__ ("%f ", d);
+
+  b = [1 2 3 4];
+  b += 1;
+  __printf_assert__ ("%f ", b);
+  __printf_assert__ ("%d ", size(b));
+  __printf_assert__ ("%s ", class(b));
+  b \= 2;
+  b -= 2;
+  b *= 2;
+  b /= 2;
+  b += 2;
+
+  b .\= 2;
+  %b .-= 2; % TODO: Removed in interpreter. Remove in VM too.
+  b .*= 2;
+  b ./= 2;
+  %b .+= 2; % TODO: Removed in interpreter. Remove in VM too.
+  b .^= 2;
+
+  __printf_assert__ ("%f ", b);
+  __printf_assert__ ("%d ", size(b));
+  __printf_assert__ ("%s ", class(b));
+
+  b = [1 2; 3 4];
+  b ^= 3;
+
+  __printf_assert__ ("%f ", b);
+  __printf_assert__ ("%d ", size(b));
+  __printf_assert__ ("%s ", class(b));
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_binops.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,117 @@
+function bytecode_binops()
+  % Root level binary expressions8
+  % should not mess up the operand stack
+  2 * 3 + 1;
+  max (3, 2) - min (3, 2);
+  sin (3) * sin (2);
+
+  % General
+  a = 1 + 2 + 3 + 4;
+  __printf_assert__ ("%.17g ", a);
+  a = -1 - 2 - 3 - 4;
+  __printf_assert__ ("%.17g ", a);
+  a = 1 * 2 * 3 * 4;
+  __printf_assert__ ("%.17g ", a);
+  a = 1 / 2 / 3 / 4;
+  __printf_assert__ ("%.17g ", a);
+  a = 1^2^3^4;
+  __printf_assert__ ("%.17g ", a);
+
+  % Order
+  a = 1 + 2 - 3 * 4 / 5 ^ 6 * 7 / 8 - 9 + 10 / 11;
+  __printf_assert__ ("%.17g ", a);
+
+  % Function calls
+  a = max (3, 2) * min (2, 1) + max (10, 9);
+  __printf_assert__ ("%.17g ", a);
+
+  % Logical
+  a = 1 && 2;
+  __printf_assert__ ("%d ", a);
+  a = 1 && 0;
+  __printf_assert__ ("%d ", a);
+  a = 1 || 2;
+  __printf_assert__ ("%d ", a);
+  a = 0 || 0;
+  __printf_assert__ ("%d ", a);
+
+  % Need to not linger on stack
+  1 && 1;
+  1 && 0;
+  0 && 1;
+  0 || 0;
+  0 || 1;
+  1 || 0;
+
+  % We wanna make sure there actually is a short circuit
+  % and that the operands are only evaluated once
+  a = truthy (1) || falsy(2);
+  __printf_assert__ ("%d ", a);
+
+  a = falsy (3) || falsy (4) || truthy (5) || falsy (6);
+  __printf_assert__ ("%d ", a);
+
+  a = truthy (7) && truthy (8) || falsy (12);
+  __printf_assert__ ("%d ", a);
+
+  a = falsy (9) && truthy (10) || falsy (11);
+  __printf_assert__ ("%d ", a);
+
+  % Compares
+
+  a = 1 == 1;
+  __printf_assert__ ("%d ", a);
+  a = 1 == 2;
+  __printf_assert__ ("%d ", a);
+  a = 1 < 2;
+  __printf_assert__ ("%d ", a);
+  a = 2 < 1;
+  __printf_assert__ ("%d ", a);
+  a = 1 > 2;
+  __printf_assert__ ("%d ", a);
+  a = 2 > 1;
+  __printf_assert__ ("%d ", a);
+  a = 1 <= 2;
+  __printf_assert__ ("%d ", a);
+  a = 2 <= 1;
+  __printf_assert__ ("%d ", a);
+  a = 1 <= 1;
+  __printf_assert__ ("%d ", a);
+  a = 1 >= 2;
+  __printf_assert__ ("%d ", a);
+  a = 2 >= 1;
+  __printf_assert__ ("%d ", a);
+  a = 1 >= 1;
+  __printf_assert__ ("%d ", a);
+  a = 2 ~= 1;
+  __printf_assert__ ("%d ", a);
+  a = 1 ~= 1;
+  __printf_assert__ ("%d ", a);
+  a = 2 != 1;
+  __printf_assert__ ("%d ", a);
+  a = 1 != 1;
+  __printf_assert__ ("%d ", a);
+
+  a = 1 == 1 && 2 > 1 && 3 > -3 || 1 < 10;
+  __printf_assert__ ("%d ", a);
+
+  % Elementwise logical
+
+  a = ones (2,2) & zeros (2,2);
+  __printf_assert__ ("%d ", a);
+  a = ones (2,2) & ones (2,2);
+  __printf_assert__ ("%d ", a);
+  a = ones (2,2) | zeros (2,2);
+  __printf_assert__ ("%d ", a);
+
+endfunction
+
+function out = truthy (i)
+  __printf_assert__ ("truthy%d ", i);
+  out = 1;
+end
+
+function out = falsy (i)
+  __printf_assert__ ("falsy%d ", i);
+  out = 0;
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_cdef_use.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,82 @@
+function bytecode_cdef_use ()
+  % The classdef handle class cdef_foo prints its ctor argument
+  % in the dtor with __printf_assert__ aswell asd
+  % adds one to the globals cdef_foo_ctor_cnt and cdef_foo_dtor_cnt
+  % in the ctor and dtor.
+
+  h1 = cdef_foo("f1");
+  __printf_assert__ (". ");
+  h1 = 2; % Triggers dtor
+  __printf_assert__ (". ");
+
+  h4 = make_obj ("f2") + make_obj ("f3"); % Two dtors will trigger here
+  __printf_assert__ (". ");
+  __printf_assert__ ("%s %d ", h4.msg, h4.val);
+
+  __printf_assert__ (". ");
+  make_obj ("f4");          % Saved in ans
+  __printf_assert__ (". "); % Wont trigger dtor since no defined return value
+  print_arg_ret_one ("call1"); % ans' dtor executed after rhs eval
+  __printf_assert__ (". ");
+
+  % Test calling function in packages. Not really a classdef
+  u = matlab.lang.makeUniqueStrings ({"a","a"});
+  __printf_assert__ ("%s %s ", u{1}, u{2});
+
+  % Check dtor call order
+  a = make_obj ("f5");
+  b = make_obj ("f6");
+  c = make_obj ("f7");
+
+  suby (); % Same tests in a subfunction
+end
+
+function suby ()
+  h1 = cdef_foo("f8");
+  __printf_assert__ (". ");
+  h1 = 2; % Triggers dtor
+  __printf_assert__ (". ");
+
+  h4 = make_obj ("f9") + make_obj ("f10"); % Two dtors will trigger here
+  __printf_assert__ (". ");
+  __printf_assert__ ("%s %d ", h4.msg, h4.val);
+
+  __printf_assert__ (". ");
+  make_obj ("f11");          % Saved in ans
+  __printf_assert__ (". "); % Wont trigger dtor since no defined return value
+  print_arg_ret_one ("call1"); % ans' dtor executed after rhs eval
+  __printf_assert__ (". ");
+
+  % Check that the classdef object is called
+  m = containers.Map;
+  m("qwe") = 2;
+  __printf_assert__ ("%d ", m("qwe"));
+  __printf_assert__ ("%d ", m("qwe")++); % Test ++-- on objects
+  __printf_assert__ ("%d ", m("qwe"));
+  __printf_assert__ ("%d ", ++m("qwe"));
+  __printf_assert__ ("%d ", m("qwe"));
+  __printf_assert__ ("%d ", m("qwe")--);
+  __printf_assert__ ("%d ", m("qwe"));
+  __printf_assert__ ("%d ", --m("qwe"));
+  __printf_assert__ ("%d ", m("qwe"));
+  % Different op code than cmd form call
+  m = containers.Map();
+  m("qwe") = 3;
+  __printf_assert__ ("%d ", m("qwe"));
+
+  __printf_assert__ (". ");
+  % Check dtor call order
+  a = make_obj ("f12");
+  b = make_obj ("f13");
+  c = make_obj ("f14");
+end
+
+
+function h = make_obj (msg)
+    h = cdef_foo (msg);
+end
+
+function a = print_arg_ret_one (msg)
+  __printf_assert__ (msg);
+  a = 1;
+end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_cell.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,65 @@
+function bytecode_cell ()
+  a = {'a','b'};
+  __printf_assert__ ("%s ", a{1});
+  __printf_assert__ ("%s ", a{2});
+  __printf_assert__ ("%s ", a{:});
+  __printf_assert__ ("%d ", size (a));
+
+  b = 'b';
+  c = 'c';
+
+  a = {b, c};
+  __printf_assert__ ("%s ", a{1});
+  __printf_assert__ ("%s ", a{2});
+  __printf_assert__ ("%s ", a{:});
+  __printf_assert__ ("%d ", size (a));
+  __printf_assert__ ("%s ", class (a{1}));
+
+  d = 'd';
+  e = 'e';
+
+  a = {b, c; d, e};
+  __printf_assert__ ("%s ", a{1});
+  __printf_assert__ ("%s ", a{3});
+  __printf_assert__ ("%s ", a{1,2});
+  __printf_assert__ ("%s ", a{2,1});
+  __printf_assert__ ("%s ", a{:});
+  __printf_assert__ ("%d ", size (a));
+
+  f = 'f';
+  g = 'g';
+  h = 'h';
+  i = 'i';
+  a = {b, c; d, e; f g; h, i; 'j', 'k'; 'l', 'm'};
+  __printf_assert__ ("%s ", a{:});
+  __printf_assert__ ("%d ", size (a));
+
+  b = 1;
+  c = 2;
+  d = 3;
+  e = 4;
+  a = {b, c; d, e};
+  __printf_assert__ ("%d ", a{1});
+  __printf_assert__ ("%d ", a{3});
+  __printf_assert__ ("%d ", a{1,2});
+  __printf_assert__ ("%d ", a{2,1});
+  __printf_assert__ ("%d ", a{:});
+  __printf_assert__ ("%d ", a{:, 1});
+  __printf_assert__ ("%d ", a{1, :});
+  __printf_assert__ ("%d ", a{:, :});  
+  __printf_assert__ ("%d ", size (a));
+  __printf_assert__ ("%s ", class (a{1}));
+
+  a = {'qwe','asd','zxc'};
+  f = a{:};
+  __printf_assert__ ("%s ", f);
+  __printf_assert__ ("%d ", size (f));
+  __printf_assert__ ("%s ", class (f));
+
+  % Command form function call subref
+  __printf_assert__ ("%d ", suby{:});
+end
+
+function a = suby()
+  a = {1,2};
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_dountil.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,115 @@
+function bytecode_dountil ()
+  i = 5;
+  do
+    __printf_assert__ ("%d ", i);
+    i--;
+  until i
+
+  i = 0;
+  do
+    i++;
+  until i >= 3
+  __printf_assert__ ("%d ", i);
+
+  i = 0;
+  ctr = 0;
+  do
+    ctr++;
+  until i++ >= 4
+  __printf_assert__ ("%d ", i);
+  __printf_assert__ ("%d ", ctr);
+
+  i = 0;
+  ctr = 0;
+  do
+    ctr++;
+  until ++i >= 4
+  __printf_assert__ ("%d ", i);
+  __printf_assert__ ("%d ", ctr);
+
+  i = 0;
+  ctr = 0;
+  do
+    i++;
+    if i == 2
+      continue
+    end
+    ctr++;
+  until i >= 4
+  __printf_assert__ ("%d ", ctr);
+  __printf_assert__ ("%d ", i);
+
+  i = 0;
+  ctr = 0;
+  do
+    i++;
+    if i == 2
+      break
+    end
+    ctr++;
+  until i >= 4
+  __printf_assert__ ("%d ", ctr);
+  __printf_assert__ ("%d ", i);
+
+  i = 0;
+  ctr = 0;
+  do
+    i++;
+    if i == 2
+      continue
+    elseif i == 3
+      break
+    end
+    ctr++;
+  until i >= 4
+  __printf_assert__ ("%d ", ctr);
+  __printf_assert__ ("%d ", i);
+
+  i = 0;
+  do
+    i++;
+    if i == 1
+      continue
+    else
+      break
+    end
+  until i > 100
+  __printf_assert__ ("%d ", i);
+
+  ctr = 0;
+  j = 0;
+  do
+    i = 0;
+    do
+      k = 0;
+      do
+        k++;
+        ctr++;
+      until k >= 2
+      i++;
+    until i > 2
+    j++;
+  until j >= 2
+  __printf_assert__ ("%d ", ctr);
+
+  i = 0;
+  do
+    i++;
+    if i == 4
+      break;
+    end
+    continue;
+  until i == 3
+  __printf_assert__ ("%d ", i); 
+
+  i = 0;
+  do
+    break
+  until i++ > 2
+  __printf_assert__ ("%d ", i);
+
+  i = 0;
+  do
+  until i++ == 2
+  __printf_assert__ ("%d ", i);
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_end.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,58 @@
+function bytecode_end ()
+
+  A = [1 2; 3 4];
+  __printf_assert__ ("%d ", A(1:end));
+
+  A(2:end) = [5 6 7];
+  __printf_assert__ ("%d ", A);
+  __printf_assert__ ("%d ", size (A));
+
+  A = [1 2; 3 4];
+  A(end, end) = 5;
+  __printf_assert__ ("%d ", A(2, 2));
+  __printf_assert__ ("%d ", A(end, end));
+
+  A = [1 2; 3 4];
+  A(end - 1, end - 1) = 6;
+  __printf_assert__ ("%d ", A(1, 1));
+  __printf_assert__ ("%d ", A(end - 1, end - 1));
+
+  A = [1:4];
+  A(end + 1) = 5;
+  __printf_assert__ ("%d ", A);
+
+  A = 1;
+  A(end) = 2;
+  __printf_assert__ ("%d ", A);
+  __printf_assert__ ("%d ", A(end));
+
+  A(end + 1) = 3;
+  __printf_assert__ ("%d ", A);
+  __printf_assert__ ("%d ", A(end));
+
+  __printf_assert__ ("%d ", suby1()(end));
+
+  % End indexing an object that is not an id
+  s = {"ifs"};
+  a = s{1}(2:end);
+  __printf_assert__ ("%s ", a);
+
+  % Nested index expressions
+  M = [1 2 3 4];
+  __printf_assert__ ("%d ", M (min (2, end))); % End of M 
+  __printf_assert__ ("%d ", M (max (3, min (2, end)))); % End of M 
+  
+  min_h = @min;
+  __printf_assert__ ("%d ", M (min_h (2, end))); % End of min_h
+
+  s = [struct struct struct];
+  s(2).name = "foo";
+  __printf_assert__ ("%s ", s(min (2, end)).name);
+
+  % end together with struct refs are annoying
+  __printf_assert__ ("%s ", s(2).name (end - 1: end));
+end
+
+function a = suby1()
+  a = [1 2 3 4];
+end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_errors.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,68 @@
+function bytecode_errors (idx)
+  % We put test dispatch last, so that we don't have
+  % to update all columns and rows each time we 
+  % add a test ...
+  run_test (idx);
+end
+
+function if_undefined_value ()
+  if qweqwe
+    a = 2;
+  end
+end
+
+function assign_undef ()
+  a = b;
+end
+
+function subsref_undef_id ()
+  a = b(1,2,3);
+end
+
+function subsref_cell_undef_id ()
+  a = b{1,2,3};
+end
+
+function wordcmd_undef_id ()
+  b 1 2 3;
+end
+
+function binary_undef ()
+  b * a;
+end
+
+function id_index_oob_error_1 ()
+  a = [1, 2];
+  b = a (3);
+end
+
+function id_index_oob_error_2 ()
+  a = [1, 2];
+  b = a (-1);
+end
+
+function binary_wrong_size_1 ()
+  a = [1 2 3] + [1 2];
+end
+
+function run_test (idx)
+  if idx == 0
+    if_undefined_value ();
+  elseif idx == 1
+    assign_undef ();
+  elseif idx == 2
+    subsref_undef_id ();
+  elseif idx == 3
+    subsref_cell_undef_id ();
+  elseif idx == 4
+    wordcmd_undef_id ();
+  elseif idx == 5
+    binary_undef ();
+  elseif idx == 6
+    id_index_oob_error_1 ();
+  elseif idx == 7
+    id_index_oob_error_2 ();
+  elseif idx == 8
+    binary_wrong_size_1 ();
+  end
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_eval_1.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,126 @@
+function bytecode_eval_1 ()
+  % Simple
+  assert (2 == eval ("2"));
+  assert (2 == eval ("2;"));
+
+  v = eval("11");
+  assert (v == 11);
+
+  % ans
+  eval ("12");
+  assert (ans == 12);
+
+  % Change variable value
+  a = 2;
+  eval ("a = 3;");
+
+  __printf_assert__ ("%f ", a)
+  __printf_assert__ ("%f ", size (a))
+  __printf_assert__ ("%s ", class (a));
+
+  % Create new variable in an eval
+  eval ("b = 4;");
+  __printf_assert__ ("%f ", b)
+  __printf_assert__ ("%f ", size (b))
+  __printf_assert__ ("%s ", class (b));
+
+  % Create new variable in an eval, that is also not
+  % not in a bytecode slot
+  eval ("c = 4;");
+  __printf_assert__ ("%f ", eval("c"))
+  __printf_assert__ ("%f ", size (eval("c")))
+  __printf_assert__ ("%s ", class (eval("c")));
+  eval ("c = 5;");
+  __printf_assert__ ("%f ", eval("c"))
+
+  % Change a global in an eval
+  clear global d
+  global d = 3;
+  eval ("d = 4;")
+  __printf_assert__ ("%f ", d);
+  clear global d
+  d = 2;
+  __printf_assert__ ("%f ", d);
+
+  % Create a global in an eval
+
+  %% TODO: Not supported. Does it have to be?
+  % eval ("clear global e");
+  % eval ("global e = 5;")
+  % __printf_assert__ ("%f ", e);
+  % __printf_assert__ ("%d ", length(who('global','e')));
+
+  % Just test the same thing in a subfunction
+  sub1 ();
+  
+  % Change the value of arguments and returns in an eval
+  % Also do nargin and nargout in a subfunction
+  [aa bb] = suby2 (11, 22, 33);
+  __printf_assert__ ("%f ", aa);
+  __printf_assert__ ("%f ", bb);
+end
+
+function sub1()
+  % Simple
+  assert (2 == eval ("2"));
+  assert (2 == eval ("2;"));
+
+  v = eval("11");
+  assert (v == 11);
+
+  % ans
+  eval ("12");
+  assert (ans == 12);
+
+  % Change variable value
+  a = 2;
+  eval ("a = 3;");
+
+  __printf_assert__ ("%f ", a)
+  __printf_assert__ ("%f ", size (a))
+  __printf_assert__ ("%s ", class (a));
+
+  % Create new variable in an eval
+  eval ("b = 4;");
+  __printf_assert__ ("%f ", b)
+  __printf_assert__ ("%f ", size (b))
+  __printf_assert__ ("%s ", class (b));
+
+  % Create new variable in an eval, that is also not
+  % not in a bytecode slot
+  eval ("c = 4;");
+  __printf_assert__ ("%f ", eval("c"))
+  __printf_assert__ ("%f ", size (eval("c")))
+  __printf_assert__ ("%s ", class (eval("c")));
+  eval ("c = 5;");
+  __printf_assert__ ("%f ", eval("c"))
+
+  % Change a global in an eval
+  clear global d
+  global d = 3;
+  eval ("d = 4;")
+  __printf_assert__ ("%f ", d);
+  clear global d
+  d = 2;
+  __printf_assert__ ("%f ", d);
+end
+
+function [c d] = suby2 (a, b, c)
+  __printf_assert__ ("1:%f ", a);
+  __printf_assert__ ("2:%f ", b);
+  __printf_assert__ ("3:%f ", c);
+
+  eval ("c = 3;")
+  eval ("a = c;")
+  eval ("d = a;")
+  __printf_assert__ ("4:%f ", a);
+  __printf_assert__ ("5:%f ", b);
+  __printf_assert__ ("6:%f ", c);
+  __printf_assert__ ("7:%f ", d);
+  
+  __printf_assert__ ("%d ", nargin);
+  __printf_assert__ ("%d ", eval ("nargin"));
+
+  __printf_assert__ ("%d ", nargout);
+  __printf_assert__ ("%d ", eval ("nargout"));
+end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_evalin_1.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,35 @@
+function bytecode_evalin_1 ()
+  b = evalin ("caller", "caller_a");
+  __printf_assert__ ("%f ", b);
+
+  evalin ("caller", "__printf_assert__('yoyo ')");
+
+  evalin ("base", "__printf_assert__('yobase ')");
+
+  caller_b = 3;
+  sub1();
+  __printf_assert__ ("%f ", caller_e);
+  __printf_assert__ ("%f ", eval ("caller_f")); % No slot for caller_f
+
+  caller_c = 11;
+  bytecode_evalin_2 ();
+  __printf_assert__ ("%f ", caller_c); % Changes to 33
+
+  %%% TODO: Can't create a variable with evalin in the treewalker
+  %%%       need to verify it aint working with the VM too.
+  %% __printf_assert__ ("%f ", caller_d); % Is initialized to 22
+
+
+end
+
+function sub1()
+  b = evalin ("caller", "caller_b");
+  __printf_assert__ ("%f ", b);
+
+  evalin ("caller", "__printf_assert__('yoyo2 ')");
+
+  evalin ("base", "__printf_assert__('yobase2 ')");
+
+  assignin ("caller", "caller_e", 123);
+  assignin ("caller", "caller_f", 124);
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_evalin_2.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,8 @@
+function bytecode_evalin_2 ()
+  __printf_assert__ ("%f ", evalin ("caller", "caller_c"));
+
+  evalin ("caller", "caller_c = 33;");
+
+  %% %Can't create local in caller in the treewalker
+  %% evalin ("caller", "caller_d = 22;");
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_for.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,188 @@
+function bytecode_for()
+  ctr = 0;
+
+  for i = 1:4
+    __printf_assert__ ("%d ", i);
+  end
+  __printf_assert__ ("%d ", i);
+
+  for i = 1:2:5
+    __printf_assert__ ("%d ", i);
+  end
+  __printf_assert__ ("%d ", i);
+
+  for i = 4:-1:1
+    __printf_assert__ ("%d ", i);
+  end
+  __printf_assert__ ("%d ", i);
+
+  for j = 1:4
+    break
+  end
+  __printf_assert__ ("%d ", j);
+
+  for j = 1:4
+    continue
+  end
+  __printf_assert__ ("%d ", j);
+
+  for j = 1:4
+    if j == 2
+      break
+    end
+  end
+  __printf_assert__ ("%d ", j);
+
+  for j = 1:4
+    if j == 2
+      break
+    else
+      continue
+    end
+  end
+  __printf_assert__ ("%d ", j);
+
+  ctr = 0;
+  for i = 1:4
+    for j = 1:4
+      ctr++;
+    end
+  end
+  __printf_assert__ ("%d ", ctr);
+
+  ctr = 0;
+  for i = 1:4
+    if i == 2
+      continue
+    end
+
+    for j = 1:4
+      if j == 2
+        continue
+      end
+      
+      ctr++;
+      
+      if j == 3
+        break
+      end
+    end
+
+    if i == 3
+      break
+    end
+  end
+  __printf_assert__ ("%d ", ctr);
+  __printf_assert__ ("%d ", i);
+  __printf_assert__ ("%d ", j);
+
+  ctr = 0;
+  for i = 1:2
+    for j = 1:2
+      for k = 1:2
+        for l = 1:2
+          for m = 1:2
+            for n = 1:2
+              for o = 1:2
+                for p = 1:2
+                  ctr++;
+                end
+              end
+            end
+          end
+        end
+      end
+    end
+  end
+  __printf_assert__ ("%d ", ctr);
+
+  for i = 1:3
+  end
+  __printf_assert__ ("%d ", i);
+
+  % sclar range, only executed once
+  for i = 2
+    __printf_assert__ ("%d ", i);
+  end
+
+  n = 1;
+  for i = 1:n
+    __printf_assert__ ("%d ", i);
+  end
+
+  n = 1;
+  for i = 2:n
+    __printf_assert__ ("boo");
+  end
+  __printf_assert__ ("%d ", i);
+  __printf_assert__ ("%s ", class (i));
+
+  %Matrix
+  M = [1 2; 3 4];
+  for i = M
+    __printf_assert__ ("%d ", i);
+    __printf_assert__ ("size %d ", size (i));
+  end
+
+  for i = []
+    __printf_assert__ ("boo");
+  end
+  __printf_assert__ ("%d ", i);
+  __printf_assert__ ("%s ", class (i));
+
+  
+  n = 'qwe';
+  for i = n
+    __printf_assert__ ("%s ", i);
+    __printf_assert__ ("size %d ", size (i));
+  end
+  __printf_assert__ ("%s ", class (i));
+
+  % The iteration variable is a double
+  % ??? Changed in someones patch? TODO: Bug?
+  for i = single(1):single(3)
+    if i == 1
+      __printf_assert__ ("%s ", class (i));
+    end
+  end
+
+  % ... unless rhs is a scalar ... 
+  for i = single (1)
+  end
+  __printf_assert__ ("%s ", class (i));
+
+  % Test return from for loop (need to pop native integers from stack)
+  __printf_assert__ ("%d ", foo ());
+
+  % Iterate over struct
+  for s = struct ("a", {"1", "2"}, "b", {"11", "12"})
+    __printf_assert__ ("%s %s ", s.a, s.b);
+  end
+
+  % Complex for loop
+
+  x.a = 1;
+  x.b = [1, 2; 3, 4];
+  x.c = "string";
+  for [val, key] = x
+    __printf_assert__ ("key:%s ", key)
+    if isa(val, "char")
+      __printf_assert__ ("val:%s ", val)
+    else
+      __printf_assert__ ("val:%d %d", val, size(val))
+    end
+  endfor
+
+  for [val, key] = struct ()
+    __printf_assert__ ("boo");
+  end
+end
+  
+
+function i = foo ()
+  for i = 1:10
+    if i == 5
+      return
+    end
+  end
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_global_1.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,201 @@
+% TODO: When clear and dynamic stack works, test
+% that behavoiur is the same when clearing globals
+% in another function while they are on the stack in the
+% caller.
+
+function bytecode_global_1 ()
+  % General test. a and b are also read and verified in test .tst file
+  global a b
+  __printf_assert__ ("%s ", class (a)); 
+  __printf_assert__ ("%d ", size (a));
+
+  __printf_assert__ ("%d ", length (who ('global','a')));
+  __printf_assert__ ("%d ", length (who ('global','b')));
+  __printf_assert__ ("%d ", isglobal ('a'));
+  __printf_assert__ ("%d ", isglobal ('b'));
+
+  a = 1;
+  __printf_assert__ ("%d ", a);
+  b = 2;
+  __printf_assert__ ("%d ", b);
+
+  a = b;
+  __printf_assert__ ("%d ", a);
+  __printf_assert__ ("%d ", b);
+  b = 100;
+  a = 3 * b + max (a, b);
+  __printf_assert__ ("%d ", a);
+  __printf_assert__ ("%d ", b);
+
+  % Test that we can make globals in subfunctions
+  global e %sub1 needs a global "e"
+  e = 11;
+  sub1 (1);
+
+  __printf_assert__ ("%d ", isglobal ('a'));
+  __printf_assert__ ("%d ", isglobal ('b'));
+  __printf_assert__ ("%d ", a);
+  __printf_assert__ ("%d ", b);
+
+  sub1 (0);
+
+  __printf_assert__ ("%d ", isglobal ('a'));
+  __printf_assert__ ("%d ", isglobal ('b'));
+  __printf_assert__ ("%d ", a);
+  __printf_assert__ ("%d ", b);
+
+  % Declare global, clear it, use identifier as local, declare
+  % it as global ...
+  global c
+  __printf_assert__ ("%d ", length (who ('global','c')));
+  clear global c;
+  __printf_assert__ ("%d ", length (who ('global','c')));
+
+  c = 2;
+  __printf_assert__ ("%d ", c);
+  __printf_assert__ ("%s ", class(c));
+
+  global c
+  __printf_assert__ ("%d ", c);
+  __printf_assert__ ("%s ", class(c));
+
+  % Subassign
+  global f
+  f = [1 2 3 4 5];
+  f(3) = 6;
+  f(1) = 11;
+  __printf_assert__ ("%d ", f);
+  __printf_assert__ ("%s ", class(f));
+  __printf_assert__ ("%d ", size (f));
+
+  % Multiassign
+  global g h
+  [g h f] = returns3 ();
+  __printf_assert__ ("%d ", g);
+  __printf_assert__ ("%s ", class(g));
+  __printf_assert__ ("%d ", size (g));
+  __printf_assert__ ("%d ", h);
+  __printf_assert__ ("%s ", class(h));
+  __printf_assert__ ("%d ", size (h));
+  __printf_assert__ ("%d ", f);
+  __printf_assert__ ("%s ", class(f));
+  __printf_assert__ ("%d ", size (f));
+
+  % Init expression
+  global k = 3;
+  __printf_assert__ ("%d ", k);
+  __printf_assert__ ("%s ", class(k));
+  __printf_assert__ ("%d ", size (k));
+
+  global l = 4 m = max (10,9) n = [2,3] o = k;
+  __printf_assert__ ("%d ", l);
+  __printf_assert__ ("%s ", class(l));
+  __printf_assert__ ("%d ", size (l));
+  __printf_assert__ ("%d ", m);
+  __printf_assert__ ("%s ", class(m));
+  __printf_assert__ ("%d ", size (m));
+  __printf_assert__ ("%d ", n);
+  __printf_assert__ ("%s ", class(n));
+  __printf_assert__ ("%d ", size (n));
+  __printf_assert__ ("%d ", o);
+  __printf_assert__ ("%s ", class(o));
+  __printf_assert__ ("%d ", size (o));
+
+  % Init expression for existing local
+  p = 2;
+  global p = 3;
+  __printf_assert__ ("%d ", p);
+  __printf_assert__ ("%s ", class(p));
+  __printf_assert__ ("%d ", size (p));
+  % q created in caller already
+  global q = 4;
+  __printf_assert__ ("%d ", q);
+  __printf_assert__ ("%s ", class(q));
+  __printf_assert__ ("%d ", size (q));
+
+  % Reinit does nothing
+  global r = 7
+  global r = 8
+  __printf_assert__ ("%d ", r);
+  __printf_assert__ ("%s ", class(r));
+  __printf_assert__ ("%d ", size (r));
+
+  clear global c
+  __printf_assert__ ("%d ", length (who ('global','c')));
+
+  clear global d
+  clear global e
+  clear global f
+  clear global g
+  clear global h
+  clear global k
+  clear global l
+  clear global m
+  clear global n
+  clear global o
+  clear global p
+  clear global r
+end
+
+function [q w e] = returns3()
+  q = 11;
+  w = 22;
+  e = 33;
+end
+
+
+function sub1(make_global)
+  % Already defined local, later declared global  
+  d = 3;
+  __printf_assert__ ("%d ", length(who('global','d')));
+  global d
+  __printf_assert__ ("%d ", length(who('global','d')));
+  __printf_assert__ ("%d ", d);
+  __printf_assert__ ("%s ", class(d));
+  __printf_assert__ ("%d ", size (d));
+  d = [1 2];
+  __printf_assert__ ("%d ", d);
+  __printf_assert__ ("%s ", class(d));
+  __printf_assert__ ("%d ", size (d));
+
+  % Already defined local, later declared global,
+  % but with the global already with a value from the caller
+  e = 4;
+  __printf_assert__ ("%d ", length(who('global','e')));
+  global e
+  __printf_assert__ ("%d ", length(who('global','e')));
+  __printf_assert__ ("%d ", e);
+  __printf_assert__ ("eclass:%s ", class(e));
+  __printf_assert__ ("%d ", size (e));
+  e = [3 4];
+  __printf_assert__ ("%d ", e);
+  __printf_assert__ ("%s ", class(e));
+  __printf_assert__ ("%d ", size (e));
+  
+
+  % Conditionally global a and b
+  if make_global
+    global a
+    global b
+
+    __printf_assert__ ("%d ", a);
+    __printf_assert__ ("%d ", b);
+  end
+
+  __printf_assert__ ("%d ", isglobal ('a'));
+  __printf_assert__ ("%d ", isglobal ('b'));
+  __printf_assert__ ("%d ", length(who('global','a')));
+  __printf_assert__ ("%d ", length(who('global','b')));
+
+  a = 3;
+  b = 4;
+
+  __printf_assert__ ("%d ", a);
+  __printf_assert__ ("%d ", b);
+
+  if make_global
+    a = 5;
+    b = 6;
+  end
+end
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_if.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,142 @@
+function bytecode_if()
+  ctr = 0;
+  a = 1;
+  b = 0;
+
+  if a
+    __printf_assert__ ("%d ", ctr++);
+  end
+
+  if a
+    __printf_assert__ ("%d ", ctr++);
+  else
+    __printf_assert__ ("booo ");
+  end
+
+  if a
+    __printf_assert__ ("%d ", ctr++);
+  elseif a
+    __printf_assert__ ("booo ");
+  else
+    __printf_assert__ ("booo ");
+  end
+
+  if b
+    __printf_assert__ ("booo ", ctr++);
+  end
+
+  if b
+    __printf_assert__ ("booo ");
+  else
+    __printf_assert__ ("%d ", ctr++);
+  end
+
+  if b
+    __printf_assert__ ("booo ");
+  elseif b
+    __printf_assert__ ("booo ");
+  else
+    __printf_assert__ ("%d ", ctr++);
+  end  
+
+  if b
+    __printf_assert__ ("booo ");
+  elseif a
+    __printf_assert__ ("%d ", ctr++);
+  else
+    __printf_assert__ ("booo ");
+  end
+
+  if a
+    if a
+      if a
+        if a
+          if a
+            if b
+              __printf_assert__ ("booo ");
+            else
+              if a
+                if a
+                  if b
+                    __printf_assert__ ("booo ");
+                  elseif a
+                    if b
+                      __printf_assert__ ("booo ");
+                    else
+                      __printf_assert__ ("%d ", ctr++);
+                    end
+                  else
+                    __printf_assert__ ("booo ");
+                  end
+                end
+              end
+            end
+          end
+        else
+          __printf_assert__ ("booo ");
+        end
+      end
+    end
+  end
+
+  if 3 > 2
+    __printf_assert__ ("%d ", ctr++);
+  end
+
+  if []
+    __printf_assert__ ("booo ");
+  end
+
+  if ~b
+    __printf_assert__ ("%d ", ctr++);
+  end
+
+  if b
+  end
+
+  % "Braindead" short circuit
+  %
+  % We also check that there is a proper short circuit
+  if truthy (1) & truthy (2)
+    __printf_assert__ ("yay1 ");
+  end
+
+  if falsy (3) & truthy (4)
+    __printf_assert__ ("booo ");
+  end
+
+  if falsy (5) & falsy (6)
+    __printf_assert__ ("booo ");
+  end
+
+  if truthy (7) & falsy (8)
+    __printf_assert__ ("booo ");
+  end
+
+  if truthy (1)| truthy (2)
+    __printf_assert__ ("yay1 ");
+  end
+
+  if falsy (3) | truthy (4)
+    __printf_assert__ ("yay2 ");
+  end
+
+  if falsy (5) | falsy (6)
+    __printf_assert__ ("booo ");
+  end
+
+  if truthy (7) | falsy (8)
+    __printf_assert__ ("yay3 ");
+  end
+end
+
+function a = truthy (b)
+  __printf_assert__ ("%d ", b);
+  a = 1;
+end
+
+function a = falsy (b)
+  __printf_assert__ ("%d ", b);
+  a = 0;
+end
+    
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_index_obj.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,63 @@
+function bytecode_index_obj ()
+
+    % Chained indexing with struct
+    __printf_assert__ ("%d ", suby1 ().a);
+    __printf_assert__ ("%d ", suby1.a); % cmd fn call
+    __printf_assert__ ("%d ", suby1 ().b.a);
+    __printf_assert__ ("%d ", suby1.b.a);
+
+    % Chained indexing with matrix
+    __printf_assert__ ("%d ", suby_mat1 ()(2));
+
+    % Chained indexing with cells
+    __printf_assert__ ("%s ", class(suby_cell1 ()(2)));
+    __printf_assert__ ("%d ", size(suby_cell1 ()(2)));
+    __printf_assert__ ("%d ", suby_cell1 (){1}{3});
+    __printf_assert__ ("%d ", suby_cell1 (){1}{3}(1));
+    __printf_assert__ ("%d ", suby_cell1 ()(1){1}{2});
+    __printf_assert__ ("%d ", suby_cell1{1}{3}); % cmd fn call
+
+    % Dynamic struct field
+    s = struct;
+    s.qwe = 22;
+    s.asd = struct ("qwe", 33);
+
+    __printf_assert__ ("%d ", s.("qwe"));
+    __printf_assert__ ("%s ", class (s.("asd").("qwe")));
+    __printf_assert__ ("%d ", s.("asd").("qwe"));
+
+    % Subassign dynamic field
+    t.qwe = 3;
+    t.("asd") = 4;
+    __printf_assert__ ("%d ", t.qwe);
+    __printf_assert__ ("%d ", t.asd);
+
+    % : and end for eg. foo()(:,end) etc
+
+    % Check that classdef metas can be used to construct a classdef object
+    h = @sin;
+    o = matlab.lang.MemoizedFunction (h);
+    __printf_assert__ ("%s ", class (o))
+
+    % Check proper argument order
+    s = [struct struct ; struct struct];
+    M = [1:10 ; 11:20];
+    s(1,2).a = M;
+    __printf_assert__ ("%d ", s(1,2).a(1,2));
+end
+
+function s = suby1()
+    s = struct;
+    s.a = 2;
+    b = struct;
+    b.a = 3;
+    s.b = b;
+end
+
+function m = suby_mat1()
+    m = [1 2 3];
+end
+
+function c = suby_cell1()
+    c = {{1 2 3}, 4, 5};
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_inputname.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,28 @@
+function bytecode_inputname (arg1, arg2)
+    __printf_assert__ ("%s ", inputname (1, 0));
+    __printf_assert__ ("%s ", inputname (1, 1));
+    __printf_assert__ ("%s ", inputname (2, 0));
+    __printf_assert__ ("%s ", inputname (2, 1));
+
+    a = 2;
+    b = 3;
+    suby (a, b);
+    suby (a + 1, b * 3);
+
+    % inputname from non-compiled function
+    inputname_args (a, b);
+    inputname_args (a + 1, b * 3);
+end
+
+function suby (arg1, arg2)
+    __printf_assert__ ("%s ", inputname (1, 0));
+    __printf_assert__ ("%s ", inputname (1, 1));
+    __printf_assert__ ("%s ", inputname (2, 0));
+    __printf_assert__ ("%s ", inputname (2, 1));
+
+    aa = 22;
+    bb = 33;
+    % inputname from non-compiled function
+    inputname_args (aa, bb);
+    inputname_args (aa + 1, bb * 3);
+end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_leaks.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,154 @@
+#
+# We are looking for leaks of octave_value:s by checking the refrence counts
+# in different code paths of the calling convention.
+#
+function [a b] = bytecode_leaks (c, d)
+  cc = c;
+  b = d;
+
+  e = 1+1;
+  refs_e = __ref_count (e);
+  suby1(e);
+  assert (refs_e, __ref_count (e))
+
+  aa = suby2(e);
+  assert (refs_e, __ref_count (e))
+
+  % Test special code path for assigning argument to return value
+  aa = suby3(e);
+  assert (refs_e + 1, __ref_count (e))
+  aa = 0;
+  assert (refs_e, __ref_count (e))
+
+  % varargin
+  suby4 (e,e,e,e)
+  assert (refs_e, __ref_count (e))
+  suby5 (e,e,e,e)
+  assert (refs_e, __ref_count (e))
+
+  % varargout
+  suby6(e);
+  assert (refs_e, __ref_count (e))
+  [tmp1, tmp2, tmp3, tmp4, tmp5] = suby6(e);
+  tmp1 = 0; tmp2 = 0; tmp3 = 0; tmp4 = 0; tmp5 = 0;
+  assert (refs_e, __ref_count (e))
+
+  suby7(e);
+  assert (refs_e, __ref_count (e))
+  [tmp1, tmp2, tmp3, tmp4, tmp5] = suby6(e);
+  tmp1 = 0; tmp2 = 0; tmp3 = 0; tmp4 = 0; tmp5 = 0;
+  assert (refs_e, __ref_count (e))
+
+  % Call non-vm function
+  sin (e);
+  assert (refs_e, __ref_count (e))
+
+  % Index matrix
+  m = [1 2 3 4];
+  m (e);
+  assert (refs_e, __ref_count (e))
+
+  % Ops
+  tmp1 = -e + e * e - e / e ^ e;
+  assert (refs_e, __ref_count (e))
+
+  % Dynamic matrix
+  m = [1 2 3 e; e 4 5 6];
+  m = 0;
+  assert (refs_e, __ref_count (e))
+
+  % Cell
+  m = {1,2,3, e; 4, 5, e, 6};
+  m = 0;
+  assert (refs_e, __ref_count (e))
+
+  % "command call" with disp
+  e
+  assert (refs_e + 1, __ref_count (e)) % in ans
+  ans = 0;
+  assert (refs_e, __ref_count (e))
+
+  % no disp
+  e;
+  assert (refs_e + 1, __ref_count (e)) % in ans
+  ans = 0;
+  assert (refs_e, __ref_count (e))
+
+
+  % Too many or few args
+  try
+    suby1 (e,e,e);
+  catch
+  end
+  assert (refs_e, __ref_count (e))
+
+  try
+    subsuby5 (e);
+  catch
+  end
+  assert (refs_e, __ref_count (e))
+
+  try
+    m = [];
+    m(e)
+  catch
+  end
+  assert (refs_e, __ref_count (e))
+
+  try
+    m = [];
+    m(e) = 123;
+  catch
+  end
+  assert (refs_e, __ref_count (e))
+  
+  % eval dynamic stack
+  suby8 (e);
+  assert (refs_e, __ref_count (e))
+end
+
+function suby1 (a)
+  aa = 1 + a;
+  bb = a;
+end
+
+function aa = suby2 (a)
+  aa = 1 + a;
+  bb = a;
+end
+
+function a = suby3(a)
+end
+
+function b = suby4(varargin)
+  b = 3 + varargin{1};
+  c = varargin{2};
+end
+
+function b = suby5(a, b, varargin)
+  b = 3 + varargin{1};
+  c = varargin{2};
+  d = a;
+end
+
+function varargout = suby6(a)
+  varargout{1} = 3;
+  varargout{2} = a;
+  varargout{3} = 1;
+  varargout{4} = 1;
+  varargout{5} = a;
+  cc = a;
+end
+
+function [aa bb varargout] = suby7(a)
+  varargout{1} = 3;
+  varargout{2} = a;
+  varargout{3} = 1;
+  aa = 1;
+  bb = a;
+  cc = a;
+end
+
+function suby8(a)
+  eval ("g = a;");
+end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_matrix.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,222 @@
+function bytecode_matrix ()
+  % Dynamically built matrixes, i.e. those
+  % who are not built by the parser, with a dynamic value
+  % inside the initializer.
+
+  a = 1;
+  b = 2;
+  c = 3;
+  d = 4;
+  A = [a b c d];
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  A = [a b c d]';
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  A = [a b; c d];
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  A = [A; A];
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  A = [];
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  % Evalorder
+  A = [hi('a') hi('b'); hi('c') hi('d')];
+
+  % Matrix multiply
+  A = [a b; c d] * [a b; c d];
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  A = [a b c d] * [a; b; c; d];
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  A = [a; b; c; d] * [a b c d];
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  % Matrix div
+  A = [a b c d] / [a b c d];
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));  
+
+  A = [a b c d] \ [a b c d];
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+  
+  A = [a b; c d] / [a b; c d];
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A)); 
+  
+  % Compound mul herm
+  A = [a b c d] * [a b c d]';
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  % Compound herm mul
+  A = [a b; c d]' * [a b; c d];
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));  
+
+  % Compound trans ldiv
+  A = [a; b; c; d].' \ [a b c d];
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  % Compound trans ldiv
+  A = [a b; c d].' \ [a b; c d];
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  % Matrix add
+  A = [a b; c d] + [a b; c d];
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  A = [a b c d] + [a; b; c; d];
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  % Scalar
+  A = [a b c d] + 2;
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  A = 2 + [a b c d];
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  A = [a b c d] - 2;
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  A = 2 * [a b c d];
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  A = [a b c d] / 2;
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  A = 2 \ [a b c d];
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  % Dot
+
+  A = [a b c d] .* [a b c d];
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  A = [a b c d] ./ [a b c d];
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  A = [a b c d] .\ [a b c d];
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  A = [a b c d] .^ [a b c d];
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  A = [a b c d] .* [a b c d]';
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  A = [a b c d] ./ [a b c d]';
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  A = [a b c d] .\ [a b c d]';
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  A = [a b c d] .^ [a b c d]';
+  __printf_assert__ ("%g ", A);
+  __printf_assert__ ("%g ", size (A));
+
+  % Matrixes with unequal row length
+  s = "zxc";
+  A = ["qweasd"; s];
+  __printf_assert__ ("%s ", A);
+  A = [s s; s];
+  __printf_assert__ ("%s ", A);
+
+  % Matrixes with more than 255 elements use
+  % a differens op-code.
+  a = 111;
+        % note a here
+  b = [ a 1   2   3   4   5   6   7   8   9  10 ...
+        11  12  13  14  15  16  17  18  19  20 ...
+        21  22  23  24  25  26  27  28  29  30 ...
+        31  32  33  34  35  36  37  38  39  40 ...
+        41  42  43  44  45  46  47  48  49  50 ...
+        51  52  53  54  55  56  57  58  59  60 ...
+        61  62  63  64  65  66  67  68  69  70 ...
+        71  72  73  74  75  76  77  78  79  80 ...
+        81  82  83  84  85  86  87  88  89  90 ...
+        91  92  93  94  95  96  97  98  99 100 ...
+        101 102 103 104 105 106 107 108 109 110 ...
+        111 112 113 114 115 116 117 118 119 120 ...
+        121 122 123 124 125 126 127 128 129 130 ...
+        131 132 133 134 135 136 137 138 139 140 ...
+        141 142 143 144 145 146 147 148 149 150 ...
+        151 152 153 154 155 156 157 158 159 160 ...
+        161 162 163 164 165 166 167 168 169 170 ...
+        171 172 173 174 175 176 177 178 179 180 ...
+        181 182 183 184 185 186 187 188 189 190 ...
+        191 192 193 194 195 196 197 198 199 200 ...
+        201 202 203 204 205 206 207 208 209 210 ...
+        211 212 213 214 215 216 217 218 219 220 ...
+        221 222 223 224 225 226 227 228 229 230 ...
+        231 232 233 234 235 236 237 238 239 240 ...
+        241 242 243 244 245 246 247 248 249 250 ...
+        251 252 253 254 255 256 257];
+  __printf_assert__ ("%d ", size (b));
+  __printf_assert__ ("%d ", sum (b));
+  a = 111;
+        % note a here
+  b = [ a;   1;   2;   3;   4;   5;   6;   7;   8;   9;  10; ...
+        11;  12;  13;  14;  15;  16;  17;  18;  19;  20; ...
+        21;  22;  23;  24;  25;  26;  27;  28;  29;  30; ...
+        31;  32;  33;  34;  35;  36;  37;  38;  39;  40; ...
+        41;  42;  43;  44;  45;  46;  47;  48;  49;  50; ...
+        51;  52;  53;  54;  55;  56;  57;  58;  59;  60; ...
+        61;  62;  63;  64;  65;  66;  67;  68;  69;  70; ...
+        71;  72;  73;  74;  75;  76;  77;  78;  79;  80; ...
+        81;  82;  83;  84;  85;  86;  87;  88;  89;  90; ...
+        91;  92;  93;  94;  95;  96;  97;  98;  99; 100; ...
+        101; 102; 103; 104; 105; 106; 107; 108; 109; 110; ...
+        111; 112; 113; 114; 115; 116; 117; 118; 119; 120; ...
+        121; 122; 123; 124; 125; 126; 127; 128; 129; 130; ...
+        131; 132; 133; 134; 135; 136; 137; 138; 139; 140; ...
+        141; 142; 143; 144; 145; 146; 147; 148; 149; 150; ...
+        151; 152; 153; 154; 155; 156; 157; 158; 159; 160; ...
+        161; 162; 163; 164; 165; 166; 167; 168; 169; 170; ...
+        171; 172; 173; 174; 175; 176; 177; 178; 179; 180; ...
+        181; 182; 183; 184; 185; 186; 187; 188; 189; 190; ...
+        191; 192; 193; 194; 195; 196; 197; 198; 199; 200; ...
+        201; 202; 203; 204; 205; 206; 207; 208; 209; 210; ...
+        211; 212; 213; 214; 215; 216; 217; 218; 219; 220; ...
+        221; 222; 223; 224; 225; 226; 227; 228; 229; 230; ...
+        231; 232; 233; 234; 235; 236; 237; 238; 239; 240; ...
+        241; 242; 243; 244; 245; 246; 247; 248; 249; 250; ...
+        251; 252; 253; 254; 255; 256; 257];
+  __printf_assert__ ("%d ", size (b));
+  __printf_assert__ ("%d ", sum (b));
+  
+end
+
+function i = hi (s)
+  __printf_assert__ ("%s ", s);
+  i = 1;
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_misc.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,11 @@
+function bytecode_misc ()
+  ## Assure "set_internal_variable" are reset properly
+  max_stack = max_stack_depth;
+  set_max_stack_depth_1p (max_stack + 1);
+  assert (max_stack_depth == max_stack);
+end
+
+function set_max_stack_depth_1p (x)
+  max_stack_depth (x + 1, "local");
+  assert (max_stack_depth == x + 1);
+end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_multi_assign.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,56 @@
+function bytecode_multi_assign ()
+  A = [1 2; 3 4];
+  [a, b] = max (A);
+  __printf_assert__ ("%d ", a);
+  __printf_assert__ ("%d ", b);
+
+  [a,b,c,d] = foo ();
+  __printf_assert__ ("%d ", a);
+  __printf_assert__ ("%d ", b);
+  __printf_assert__ ("%d ", c);
+  __printf_assert__ ("%d ", d);
+
+  % Non ids in lhs
+  % Eval is used as a cheat since
+  % rhs need to know how many lhs values 
+  % there are.
+
+  [e, f.a, g, h.b] = foo ();
+  __printf_assert__ ("%d ", e);
+  __printf_assert__ ("%d ", f.a);
+  __printf_assert__ ("%d ", g);
+  __printf_assert__ ("%d ", h.b);
+
+  e = [1 2 3];
+  g = {1, 2, 3};
+  [e(2), f.a, g{2}, h.b] = foo ();
+  __printf_assert__ ("%d ", e);
+  __printf_assert__ ("%d ", f.a);
+  __printf_assert__ ("%d ", g{2});
+  __printf_assert__ ("%d ", h.b);
+
+  [e(end), f.a, g{min (100, end)}, h.b] = foo ();
+  __printf_assert__ ("%d ", e);
+  __printf_assert__ ("%d ", f.a);
+  __printf_assert__ ("%d ", g{min (100, end)});
+  __printf_assert__ ("%d ", h.b);
+
+  [e(end), f.a, ~, h.b] = foo ();
+  __printf_assert__ ("%d ", e);
+  __printf_assert__ ("%d ", f.a);
+  __printf_assert__ ("%d ", g{end});
+  __printf_assert__ ("%d ", h.b);
+
+  
+  [C{1:2}, D] = {1,2,3}{:};
+  __printf_assert__ ("%d ", C{1});
+  __printf_assert__ ("%d ", C{2});
+  __printf_assert__ ("%d ", D);
+end
+
+function [a,b,c,d] = foo ()
+  a = 1;
+  b = 2;
+  c = 3;
+  d = 4;
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_persistant.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,23 @@
+function bytecode_persistant ()
+  q = 3;
+  l = 4;
+  
+  persistent a = 3;
+  __printf_assert__ ("a:%d ", a++);
+
+  persistent b;
+  __printf_assert__ ("b:%d ", b);
+  __printf_assert__ ("%s ", class (b));
+  __printf_assert__ ("%d ", size (b));
+  b = 0;
+  __printf_assert__ ("%d ", b++);
+
+  suby ();
+  suby ();
+end
+
+function suby ()
+  persistent c = 2;
+  c++;
+  __printf_assert__ ("c:%d ", c);
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_range.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,68 @@
+function bytecode_range ()
+
+  % The should be range constants, but I think
+  % negative limits are not folded to range constants
+  
+  a = 1:3;
+  __printf_assert__ ("%d ", a);
+
+  a = 1:2:6;
+  __printf_assert__ ("%d ", a);
+
+  a = 1:2:5;
+  __printf_assert__ ("%d ", a);
+
+  a = 1:0.1:1.4;
+  __printf_assert__ ("%d ", a);
+
+  a = 1:-0.1:0.7;
+  __printf_assert__ ("%d ", a);
+
+  a = 7:7;
+  __printf_assert__ ("%d ", a);
+
+  a = 7:-1:7;
+  __printf_assert__ ("%d ", a);
+
+  a = 7:-1:8;
+  __printf_assert__ ("%d ", isempty (a));
+
+  % Dynamically created with COLON2 or 3 opcode.
+  % Colons behave differently when in command expression,
+  % they use the COLONX_CMD opcodes.
+  %
+  % ??? I don't think the ranges are allocated as matrixes
+  % when used in commands.
+  base = 8;
+  inc = 2;
+  lim = 11;
+
+  a = base : inc : lim;
+  __printf_assert__ ("%d ", a);
+  for i = base : inc : lim
+    __printf_assert__ ("%d ", i);
+  end
+
+  a = base : lim;
+  __printf_assert__ ("%d ", a);
+  for i = base : lim
+    __printf_assert__ ("%d ", i);
+  end
+
+  base = 10;
+  inc = -2;
+  lim = 7;
+
+  a = base : inc : lim;
+  __printf_assert__ ("%d ", a);
+  for i = base : inc : lim
+    __printf_assert__ ("%d ", i);
+  end
+
+  a = -base : -lim;
+  __printf_assert__ ("%d ", a);
+  for i = -base : -lim
+    __printf_assert__ ("%d ", i);
+  end
+
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_return.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,93 @@
+function bytecode_return ()
+  a = foo ();
+  __printf_assert__ ("%d ", a);
+
+  bar (1);
+  bar (0);
+  baz (0);
+  baz (1);
+  baz (2);
+
+  boz();
+
+  meh ();
+
+  a = return_1 ();
+  __printf_assert__ ("%d ", a);
+  [a b] = return_2 ();
+  __printf_assert__ ("%d ", a);
+  __printf_assert__ ("%d ", b);
+
+  % Drop one output variable
+  a = return_2 ();
+  __printf_assert__ ("%d ", a);
+
+  % Drop all output variables
+  return_2 ();
+
+
+  % Command form call
+  a = return_1;
+  __printf_assert__ ("%d ", a);
+
+  [a b] = return_2;
+  __printf_assert__ ("%d ", a);
+  __printf_assert__ ("%d ", b);
+
+  a = return_2;
+  __printf_assert__ ("%d ", a);
+
+  return_2;
+
+  silly();
+  silly(2);
+end
+
+function [a b] = silly(i)
+  __printf_assert__ ("silly ");
+end
+
+function a = return_1 ()
+  a = 1;
+end
+
+function [a b] = return_2 ()
+  a = 1;
+  b = 2;
+end
+
+function out = foo ()
+  out = 2;
+  return
+end
+
+function bar (i)
+  if i
+    __printf_assert__ ("baaar ");
+    return
+  end
+
+  __printf_assert__ ("bääär ");
+end
+
+function out = baz (i)
+  if i == 0
+    __printf_assert__ ("baaaaz ");
+    return
+  else i == 1
+    __printf_assert__ ("bääääz ");
+    return
+  end
+
+  __printf_assert__ ("bååååz ");
+end
+
+function boz ()
+  __printf_assert__ ("booz ");
+  return
+  __printf_assert__ ("booo ");
+end
+
+function meh ()
+  return
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_struct.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,24 @@
+function bytecode_struct ()
+  s = struct ('a', 1, 'b', 2);
+  __printf_assert__ ("%d ", s.a);
+  __printf_assert__ ("%d ", s.b);
+  __printf_assert__ ("%s ", class (s.a));
+  __printf_assert__ ("%d ", size (s.a));
+
+  % Should not mess up stack
+  s.a;
+
+  % Test simple assigns
+  r.a = 3;
+
+  __printf_assert__ ("%s ", class (r));
+  __printf_assert__ ("%d ", r.a);
+
+  % Test word command struct subref
+
+  __printf_assert__ ("%d ", suby.b);
+end
+
+function a = suby ()
+  a.b = 4;
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_subfuncs.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,128 @@
+function bytecode_subfuncs (h_to_anon_fn)
+  a = foo ();
+  __printf_assert__ ("%.17g ", a);
+  b = bar ();
+  __printf_assert__ ("%.17g ", b);
+  c = baz ();
+  __printf_assert__ ("%.17g ", c);
+
+  meh ();
+
+  a = para_ret_same_name (11);
+  __printf_assert__ ("%.17g ", a);
+
+  % Test default args
+  a = defaultarg ();
+  __printf_assert__ ("%.17g ", a);
+
+  a = defaultarg (10);
+  __printf_assert__ ("%.17g ", a);
+
+  a = defaultarg2 ();
+  __printf_assert__ ("%.17g ", a);
+
+  a = defaultarg2 (11);
+  __printf_assert__ ("%.17g ", a);
+
+  a = defaultarg2 (11, 12, 13, 14);
+  __printf_assert__ ("%.17g ", a);
+
+  % Magic colon
+  a = defaultarg2 (11, :, 13, 14);
+  __printf_assert__ ("%.17g ", a);
+
+  % Functions handles
+  h = @max;
+  __printf_assert__ ("%d ", h ([1 3]));
+  __printf_assert__ ("%d ", just_call_handle_with_arg (h, [1 3]));
+  __printf_assert__ ("%d ", just_call_handle_with_arg_bytecode (h, [1 3]));
+
+  h = @foo;
+  __printf_assert__ ("%d ", h ());
+  __printf_assert__ ("%d ", just_call_handle_with_arg (h));
+  __printf_assert__ ("%d ", just_call_handle_with_arg_bytecode (h));
+
+  % Call an anonymous function from the tst-file
+  h_to_anon_fn ();
+
+  % Many args and returns
+  [a01, a02, a03, a04, a05, a06, a07, a08, a09, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32] = ret32 ();
+  __printf_assert__ ("%d ", a01, a02, a03, a04, a05, a06, a07, a08, a09, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32)
+  __printf_assert__ ("%d ", ret32 ()); % nargout = 1
+  ret32 () % nargout = 0
+  [args32{1:32}] = ret32 ();
+  __printf_assert__ ("%d ", args32{:})
+
+  [a01, a02, a03, a04, a05, a06, a07, a08, a09, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32] = ret32take32 (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32);
+  __printf_assert__ ("%d ", a01, a02, a03, a04, a05, a06, a07, a08, a09, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32)
+
+  take32 (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32);
+
+  [a01, a02, a03, a04, a05, a06, a07, a08, a09, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, ...
+   a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64] = ...
+      takeXp32retXp32 (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, ...
+                       33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64);
+  __printf_assert__ ("%d ", a01, a18, a59, a64)
+end
+
+function [a01, a02, a03, a04, a05, a06, a07, a08, a09, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, varargout] = takeXp32retXp32 (b01, b02, b03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, varargin)
+  for i = 1:32
+    eval (sprintf ("a%02.f = b%02.f;", i, i));
+  end
+  varargout = varargin;
+end
+
+function take32 (b01, b02, b03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32)
+  __printf_assert__ ("take32:");
+  __printf_assert__ ("%d ", b01, b02, b03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32);
+end
+
+function [a01, a02, a03, a04, a05, a06, a07, a08, a09, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32] = ret32 ()
+  __printf_assert__ ("ret32:");
+  for i = 1:32
+    eval (sprintf ("a%02.f = %f;", i, i));
+  end
+end
+
+function [a01, a02, a03, a04, a05, a06, a07, a08, a09, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32] = ret32take32 (b01, b02, b03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32)
+  for i = 1:32
+    eval (sprintf ("a%02.f = b%02.f;", i, i));
+  end
+end
+
+function out = just_call_handle_with_arg_bytecode (h, varargin)
+  out = h (varargin{:});
+end
+
+function out = foo ()
+  out = 2;
+end
+
+function out = bar ()
+  out = foo ();
+end
+
+function out = baz ()
+  out = bar ();
+end
+
+function meh()
+end
+
+function i = para_ret_same_name (i)
+end
+
+function a = defaultarg (b = 30)
+  a = b;
+end
+
+function a = defaultarg2 (a = 30, b = max (4, 5), c = [], d = [1 2])
+  __printf_assert__ ("%.17g ", a);
+  __printf_assert__ ("%.17g ", b);
+  __printf_assert__ ("%.17g ", c);
+  __printf_assert__ ("%d ", size(c));
+  __printf_assert__ ("%s ", class(c));
+  __printf_assert__ ("%.17g ", d);
+  __printf_assert__ ("%d ", size(d));
+  __printf_assert__ ("%s ", class(d));
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_subsasgn.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,95 @@
+function bytecode_subsasgn ()
+  A = [1 2; 3 4];
+  A(1) = 3;
+  __printf_assert__ ("%d ", A(1));
+
+  A(1,2) = 5;
+  __printf_assert__ ("%d ", A(1,2));
+
+  A(:,1) = [9;8];
+  __printf_assert__ ("%d ", A(:,1));
+
+  A(:,:) = [11 12; 13 14];
+  __printf_assert__ ("%d ", A(:,1));
+
+  B = [1:10];
+  B(7:end) = [77 88 99 1010];
+  __printf_assert__ ("%d ", B);
+  B(4:min (5, end)) = 987;
+  __printf_assert__ ("%d ", B);
+
+  % Subassign to a undefined variable
+  C(3,2) = 13;
+  __printf_assert__ ("%d ", C);
+  __printf_assert__ ("%s ", class (C));
+  __printf_assert__ ("%d ", size (C));
+
+  % Subassign cells
+  D = {1,2,3};
+  D{1} = 4;
+  __printf_assert__ ("%d ", D{:});
+  __printf_assert__ ("%s ", class (D));
+  __printf_assert__ ("%d ", size (D));
+
+  D{2,3} = {6,7};
+  dd = D{2,3};
+  __printf_assert__ ("%d ", dd{:});
+  __printf_assert__ ("%d ", size (D));
+
+  E = {1,2,3};
+  E(2:3) = {4,5};
+  __printf_assert__ ("%d ", E{:});
+
+  % Use cells as a subscript
+  M = [1 2 3; 3 4 5; 5 6 7];
+  s = {":", [1;2]};
+  __printf_assert__ ("%d ", M(s{:}));
+  M(s{:}) = 7;
+  __printf_assert__ ("%d ", M(s{:}));
+
+  % Assure that sources are not modified
+  x = [1 2 3];
+  y = x;
+  y(2) = 3;
+  __printf_assert__ ("%d %d ", x, y);
+
+  x = {1 2 3};
+  y = x;
+  y{2} = 3;
+  __printf_assert__ ("%d %d ", x{2}, y{2});
+
+  % Chained assigns
+  a.b.c.d = 2;
+  __printf_assert__ ("%d ", a.b.c.d);
+  a.("a").c.d = 3;
+  __printf_assert__ ("%d ", a.a.c.d);
+  q.w = {{1},{2}};
+  __printf_assert__ ("%d ", q.w{1}{1});
+  q.w{1} = {3};
+  __printf_assert__ ("%d ", q.w{1}{1});
+
+  z.x.c = [1 2 3];
+  __printf_assert__ ("%d ", z.x.c);
+  z.x.c(:) = 4;
+  __printf_assert__ ("%d ", z.x.c);
+
+  x = {[1 2 3], [4 5 6]; [8 9 10], [11 12 13]};
+  q.y = {{}, {}; {} {}};
+  q.y{1, 2} = x;
+  q.y{1, 2}{2, 1} = 3;
+
+  __printf_assert__ ("%d ", q.y{1, 2}{2, 1});
+  __printf_assert__ ("%d ", q.y{1, 2}{1, 2});
+
+  % += etc
+  A = [1 2 3 4];
+  A(2) += 3;
+  __printf_assert__ ("%d ", A);
+  A(3) -= 4;
+  __printf_assert__ ("%d ", A);
+
+  C = struct ();
+  C.A = A;
+  C.A(4) *= 2;
+  __printf_assert__ ("%d ", C.A);
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_switch.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,164 @@
+function bytecode_switch ()
+  a = 2;
+  switch (a)
+    case 1
+      __printf_assert__ ("boo ");
+    case 2
+      __printf_assert__ ("yay ");
+    otherwise
+      __printf_assert__ ("boo ");
+  end
+
+  switch (a)
+    case 1
+      __printf_assert__ ("boo ");
+    case 3
+      __printf_assert__ ("boo ");
+    otherwise
+      __printf_assert__ ("yay2 ");
+  end
+
+  b = "yay3 ";
+  switch (b)
+    case "boo1"
+      __printf_assert__ ("boo ");
+    case "yay3 "
+      __printf_assert__ ("yay3 ");
+    otherwise
+      __printf_assert__ ("boo ");
+  end
+
+  % Cells
+  a = 2;
+  switch (a)
+    case {1,0}
+      __printf_assert__ ("boo ");
+    case {2,3}
+      __printf_assert__ ("yay4 ");
+    otherwise
+      __printf_assert__ ("boo ");
+  end
+
+  switch (a)
+    case {1,0}
+      __printf_assert__ ("boo ");
+    case {3,2} %Swapped
+      __printf_assert__ ("yay5 ");
+    otherwise
+      __printf_assert__ ("boo ");
+  end
+
+  switch (a)
+    case {1,0}
+      __printf_assert__ ("boo ");
+    case {3,4}
+      __printf_assert__ ("boo ");
+    otherwise
+      __printf_assert__ ("yay6 ");
+  end
+
+  % Silly
+  switch (a)
+    otherwise
+      __printf_assert__ ("yay7 ");
+  end
+
+  % Empty
+  switch (a)
+  end
+
+  % No default case
+  a = 2;
+  switch (a)
+    case 1
+      __printf_assert__ ("boo ");
+    case 2
+      __printf_assert__ ("yay8 ");
+  end
+
+  switch (a)
+    case 1
+      __printf_assert__ ("boo ");
+    case 3
+      __printf_assert__ ("boo ");
+  end
+
+  % Return from switch
+  __printf_assert__ ("%d ", returnfromswitch (1));
+  __printf_assert__ ("%d ", returnfromswitch (2));
+  __printf_assert__ ("%d ", returnfromswitch (3));
+  __printf_assert__ ("%d ", returnfromswitch2 (1));
+  __printf_assert__ ("%d ", returnfromswitch2 (2));
+  __printf_assert__ ("%d ", returnfromswitch2 (3));
+
+  % switch with continue
+
+  for i = 1:4
+    switch (i)
+      case 1
+        __printf_assert__ ("1:%d ", i);
+      case 2
+        __printf_assert__ ("2:%d ", i);
+        continue;
+      case 3
+        __printf_assert__ ("3:%d ", i);
+      otherwise
+        __printf_assert__ ("breaking:%d ", i);
+        break;
+    endswitch
+    __printf_assert__ ("for-end:%d", i);
+  end
+
+end
+
+
+function a = returnfromswitch (b)
+  switch (b)
+    case 1
+      a = 1;
+      return
+    case 2
+      a = 2;
+      return;
+    otherwise
+      a = 3;
+      return
+  end
+
+  __printf_assert__ ("boo ");
+end
+
+function a = returnfromswitch2 (b)
+  % switches and fors cleans the stack at returns
+  % in a special way so test that that works properly
+  %
+  % The for loops puts native ints on the stack, so we can't just pop
+  % the stack assuming everything is octave values.
+  %
+  for i = [1, 2] % Puts int n,int i and the range on the stack
+    switch (b) % Puts b on the stack
+      case 10
+        return
+      otherwise
+        for j = [3, 4] % Puts int n,int i and the range on the stack
+          __printf_assert__ ("%d ", j);
+          switch (b) % Puts b on the stack
+            case 1
+              a = 1;
+              return %pop, popint popint pop, pop, popint popint pop
+            case 2
+              a = 2;
+            otherwise
+              a = 3;
+              return
+          end
+
+          __printf_assert__ ("%d ", j);
+        end
+    end
+
+    __printf_assert__ ("%d ", i);
+  end
+
+  __printf_assert__ ("yoo ");
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_trycatch.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,173 @@
+function bytecode_trycatch ()
+  % TODO: Check identifier in error object too
+
+  try
+    __printf_assert__ ("yay ");
+  catch
+    __printf_assert__ ("boo ");
+  end
+
+  try
+    __printf_assert__ ("yay2 ");
+    error ("ooo");
+    __printf_assert__ ("boo ");
+  catch
+    __printf_assert__ ("yay3 ");
+
+    __printf_assert__ ("%s ", getfield (lasterror (), 'message'));
+  end
+
+  % Empty body/catch
+  try
+  catch
+    __printf_assert__ ("boo ");
+  end
+
+  try
+  catch
+  end
+
+  try
+  catch err
+  end
+
+  try
+    error("foo");
+  catch
+  end
+  
+  % Error object
+  try
+    __printf_assert__ ("yay2 ");
+    error ("ooo2");
+    __printf_assert__ ("boo ");
+  catch err
+    __printf_assert__ ("yay3 ");
+
+    __printf_assert__ ("%s ", getfield (lasterror (), 'message'));
+    __printf_assert__ ("%s ", getfield (err, 'message'));
+  end
+
+  % Nested
+  try
+    __printf_assert__ ("yay3 ");
+    try
+      __printf_assert__ ("yay4 ");
+      error ("Nested error");
+      __printf_assert__ ("boo ");
+    catch
+      __printf_assert__ ("%s ", getfield (lasterror (), 'message'));
+      try
+        __printf_assert__ ("yay5 ");
+        error ("In catch");
+        __printf_assert__ ("boo ");
+      catch
+        __printf_assert__ ("yay6 ");
+        __printf_assert__ ("%s ", getfield (lasterror (), 'message'));
+      end
+    end
+
+    error ("qwe");
+    __printf_assert__ ("boo ");
+  catch
+    __printf_assert__ ("yay7 ");
+    __printf_assert__ ("%s ", getfield (lasterror (), 'message'));
+  end
+
+  % Unwind subfunction
+  try
+    suby ();
+  catch
+    __printf_assert__ ("yay8 ");
+    __printf_assert__ ("%s ", getfield (lasterror (), 'message'));
+  end
+
+  % Catch undefined id
+  try
+    qwe = asd;
+    __printf_assert__ ("boo ");
+  catch
+    __printf_assert__ ("yay9 ");
+    __printf_assert__ ("%s ", getfield (lasterror (), 'message'));
+  end
+  % Catch unconformant arguments
+  try
+    a = [1 2];
+    b = [1 2 3];
+    c = a * b;
+  catch
+    __printf_assert__ ("yay10 ");
+    __printf_assert__ ("%s ", getfield (lasterror (), 'message'));
+  end
+
+  % Rethrow
+  try
+    try
+      error ("yoyo");
+    catch err
+      rethrow (err);
+      __printf_assert__ ("boo ");
+    end
+  catch
+    __printf_assert__ ("yay11 ");
+    __printf_assert__ ("%s ", getfield (lasterror (), 'message'));
+  end
+
+  % There are some shenanigans going on poping native ints belonging
+  % to for-loops' iteration counters going on, so test that.
+  for i = 1:3
+    try
+      error ("foo");
+    catch
+      __printf_assert__ ("yay12 ");
+    __printf_assert__ ("%s ", getfield (lasterror (), 'message'));
+    end
+  end
+
+  % switch statements save the value on the stack so add some switches
+  % to check that they are unwound properly nested in fors etc
+
+  zxc = '1';
+  switch zxc
+    case '1'
+      for m = 1:3
+      end
+      switch m
+        case 2
+      end
+ 
+      for i = 1:3
+        try
+          qwe = '1';
+          switch qwe
+            case '1'
+              for j = 1:3
+                asd = '1';
+                switch asd
+                  case '1'
+                    error ("foo");
+                end
+
+                for k = 1:3
+                end
+              end
+          end      
+        catch
+          __printf_assert__ ("yay13 ");
+          __printf_assert__ ("%s ", getfield (lasterror (), 'message'));
+        end
+      end
+
+      for l = 1:2
+      end
+  end
+  % TODO: Test more types of errors ...
+end
+
+function suby ()
+  for j = 1:2
+    for i = 1:3
+      error ("Error in subfunction");
+    end
+  end
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_unary.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,22 @@
+function bytecode_unary ()
+  a = 1;
+  a = -a;
+  __printf_assert__ ("%d ", a);
+
+  c = +4;
+  b = +c;
+  __printf_assert__ ("%d ", c);
+
+  a = [1 2; 3 4]';
+  __printf_assert__ ("%d ", a);
+  a = a';
+  __printf_assert__ ("%d ", a);
+
+  b = true;
+  b = ~b;
+  __printf_assert__ ("%d ", b);
+
+  b = true;
+  b = !b;
+  __printf_assert__ ("%d ", b);
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_unwind.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,170 @@
+function bytecode_unwind ()
+  unwind_protect
+    __printf_assert__ ("yay1 ");
+  unwind_protect_cleanup
+    __printf_assert__ ("yay2 ");
+  end
+
+  try
+    unwind_protect
+      error ("e1");
+      __printf_assert__ ("boo ");
+    unwind_protect_cleanup
+      __printf_assert__ ("yay3 ");
+    end
+  catch e
+    __printf_assert__ ("%s ", getfield (e, 'message'));
+  end
+
+  suby (1);
+  suby (2);
+
+  try
+    suby (3);
+  catch
+  end
+  
+  suby (4);
+  suby (5);
+  suby (6);
+
+  % Break and returns that are not executed
+  %
+  % The combination "break and return", "break" and "return"
+  % takes different codepaths in the walker so we test all 
+  % combinations here.
+
+  unwind_protect
+    for i = 1:3
+      if i == 4
+        break
+      elseif i == 5
+        return
+      end
+    end
+  unwind_protect_cleanup
+    __printf_assert__ ("yay4 ");
+  end
+
+  % Break only
+  unwind_protect
+    for i = 1:3
+      if i == 4
+        break
+      end
+    end
+  unwind_protect_cleanup
+    __printf_assert__ ("yay5 ");
+  end
+
+  % Return only
+  unwind_protect
+    for i = 1:3
+      if i == 4
+        return
+      end
+    end
+  unwind_protect_cleanup
+    __printf_assert__ ("yay6 ");
+  end
+end
+
+function suby (a)
+  if a == 1
+    unwind_protect
+      __printf_assert__ ("subyyay1 ");
+      return
+      __printf_assert__ ("boo ");
+    unwind_protect_cleanup
+      __printf_assert__ ("subyyay2 "); 
+    end
+    __printf_assert__ ("boo ");
+  elseif a == 2
+    % Nested unwind protect with return in body
+    unwind_protect
+      unwind_protect
+        __printf_assert__ ("subyyay3 ");
+        return
+        __printf_assert__ ("boo ");
+      unwind_protect_cleanup
+        __printf_assert__ ("subyyay4 "); 
+      end
+      __printf_assert__ ("boo ");
+    unwind_protect_cleanup
+      __printf_assert__ ("subyyay5 "); 
+    end
+    __printf_assert__ ("boo ");
+  elseif a == 3
+    % Nested unwind protect with error in body
+    unwind_protect
+      unwind_protect
+        __printf_assert__ ("subyyay6 ");
+        error foooo
+        __printf_assert__ ("boo ");
+      unwind_protect_cleanup
+        __printf_assert__ ("subyyay7 "); 
+      end
+      __printf_assert__ ("boo ");
+    unwind_protect_cleanup
+      __printf_assert__ ("subyyay8 "); 
+    end
+    __printf_assert__ ("boo ");
+  elseif a == 4
+    for i = 1:3
+      unwind_protect
+        __printf_assert__ ("subyyay9 ");
+        break;
+        __printf_assert__ ("boo ");
+      unwind_protect_cleanup
+        __printf_assert__ ("subyyay10 "); 
+      end
+      __printf_assert__ ("boo ");
+    end
+  elseif a == 5
+    for i = 1:3
+      unwind_protect
+        __printf_assert__ ("subyyay11 ");
+        for j = 1:3
+          unwind_protect
+            __printf_assert__ ("subyyay12 ");
+            break;
+            __printf_assert__ ("boo ");
+          unwind_protect_cleanup
+            __printf_assert__ ("subyyay13 "); 
+          end
+          __printf_assert__ ("boo ");
+        end
+        break;
+        __printf_assert__ ("boo ");
+      unwind_protect_cleanup
+        __printf_assert__ ("subyyay14 "); 
+      end
+      __printf_assert__ ("boo ");
+    end
+  elseif a == 6
+    % Mixing unwind protect with for loops. error and break
+    for i = 1:3
+      unwind_protect
+        __printf_assert__ ("subyyay15 ");
+        try
+          for j = 1:3
+            unwind_protect
+              __printf_assert__ ("subyyay16 ");
+              error ('qwe');
+              __printf_assert__ ("boo ");
+            unwind_protect_cleanup
+              __printf_assert__ ("subyyay17 "); 
+            end
+            __printf_assert__ ("boo ");
+          end
+        catch
+          break;
+        end
+        __printf_assert__ ("boo ");
+      unwind_protect_cleanup
+        __printf_assert__ ("subyyay18 "); 
+      end
+      __printf_assert__ ("boo ");
+    end
+  end
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_varargin.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,64 @@
+function bytecode_varargin (b, varargin)
+  __printf_assert__ ("%d ", varargin{:});
+  __printf_assert__ ("%d ", size (varargin))
+
+  varg1 (1);
+  varg1 (1,2,3,4);
+  varg1 ();
+
+  varg2 (1,2,3,4);
+  varg2 (1);
+
+  cslist = {1,2,3,4};
+  varg2 (cslist{:});
+
+  justnamenotpos (1, 2);
+
+  out = inout (1,2,3,4);
+  __printf_assert__ ("%d ", out{:});
+
+  __printf_assert__ ("%d ", nargin);
+
+  % TODO: Check in caller that return is the same
+  % b = varargin{:}
+
+  suby (1,2,3);
+end
+
+function varg1 (varargin)
+  __printf_assert__ ("%d ", varargin{:});
+  __printf_assert__ ("%d ", size (varargin));
+  __printf_assert__ ("%d ", nargin);
+end
+
+function varg2 (a, varargin)
+  __printf_assert__ ("%d ", a);
+  __printf_assert__ ("%d ", varargin{:});
+  __printf_assert__ ("%d ", size (varargin));
+  __printf_assert__ ("%d ", nargin);
+
+  varg1 (varargin{:})
+  varg1 (2, varargin{:})
+end
+
+function justnamenotpos (varargin, a)
+  __printf_assert__ ("%d ", a);
+  __printf_assert__ ("%d ", varargin);
+  __printf_assert__ ("%d ", nargin);
+end
+
+function [varargin] = inout (varargin)
+  __printf_assert__ ("%d ", nargin);
+end
+
+function suby(a,b,c)
+  __printf_assert__ ("%d ", nargin);
+
+  if nargin == 3
+    suby (1,2);
+  elseif nargin == 2
+    suby (1);
+  elseif nargin == 1
+    suby ();
+  end
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_varargout.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,65 @@
+function bytecode_varargout ()
+        disp ("foobar")
+    % Just check this works
+    [a b] = {7, 8}{:};
+    __printf_assert__ ("%d %d ", a, b);
+
+    % n amount of vargouts from suby1(n)
+    a = suby1 (1);
+    __printf_assert__ ("%d ", a);
+    [a b] = suby1 (2);
+    __printf_assert__ ("%d %d ", a, b);
+
+    % Test that ignored outputs are set properly
+    % when calling interpreted functions.
+    %
+    % return_isargout (n) returns isargout (n) in its
+    % first output.
+    [a b c] = return_isargout (2);
+    __printf_assert__ ("%d ", a);
+
+    [a b c] = return_isargout (4);
+    __printf_assert__ ("%d ", a);
+ disp ("foobar2")
+    [a, ~, c] = return_isargout (2);
+    __printf_assert__ ("%d ", a);
+ disp ("foobar22")
+    [a, ~, ~] = return_isargout (2);
+    __printf_assert__ ("%d ", a);
+    [a, ~, ~] = return_isargout (1);
+    __printf_assert__ ("%d ", a);
+    [a, ~, ~] = return_isargout (3);
+    __printf_assert__ ("%d ", a);
+
+    [~, ~, ~] = return_isargout (3);
+
+    % Do the same for a vm function
+    [a b c] = sub_return_isargout (2);
+    __printf_assert__ ("%d ", a);
+
+    [a b c] = sub_return_isargout (4);
+    __printf_assert__ ("%d ", a);
+
+    [a, ~, c] = sub_return_isargout (2);
+    __printf_assert__ ("%d ", a);
+
+    [a, ~, ~] = sub_return_isargout (2);
+    __printf_assert__ ("%d ", a);
+    [a, ~, ~] = sub_return_isargout (1);
+    __printf_assert__ ("%d ", a);
+    [a, ~, ~] = sub_return_isargout (3);
+    __printf_assert__ ("%d ", a);
+
+    [~, ~, ~] = sub_return_isargout (3);
+end
+
+function [a b c ] = sub_return_isargout (n)
+    b = 0; c = 0;
+    a = isargout (n);
+end
+
+function varargout = suby1(n)
+    for i = 1:n
+        varargout{i} = i;
+    end
+end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_while.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,111 @@
+function bytecode_while ()
+  i = 5;
+  while i
+    __printf_assert__ ("%d ", i);
+    i--;
+  end
+
+  i = 0;
+  while i < 3
+    i++;
+  end
+  __printf_assert__ ("%d ", i);
+
+  i = 0;
+  ctr = 0;
+  while i++ < 4
+    ctr++;
+  end
+  __printf_assert__ ("%d ", i);
+  __printf_assert__ ("%d ", ctr);
+
+  i = 0;
+  ctr = 0;
+  while ++i < 4
+    ctr++;
+  end
+  __printf_assert__ ("%d ", i);
+  __printf_assert__ ("%d ", ctr);
+
+  i = 0;
+  ctr = 0;
+  while i < 4
+    i++;
+    if i == 2
+      continue
+    end
+    ctr++;
+  end
+  __printf_assert__ ("%d ", ctr);
+  __printf_assert__ ("%d ", i);
+
+  i = 0;
+  ctr = 0;
+  while i < 4
+    i++;
+    if i == 2
+      break
+    end
+    ctr++;
+  end
+  __printf_assert__ ("%d ", ctr);
+  __printf_assert__ ("%d ", i);
+
+  i = 0;
+  ctr = 0;
+  while i < 4
+    i++;
+    if i == 2
+      continue
+    elseif i == 3
+      break
+    end
+    ctr++;
+  end
+  __printf_assert__ ("%d ", ctr);
+  __printf_assert__ ("%d ", i);
+
+  i = 0;
+  while i < 4
+    i++;
+    if i == 1
+      continue
+    else
+      break
+    end
+  end
+  __printf_assert__ ("%d ", i);
+
+  ctr = 0;
+  j = 0;
+  while j < 2
+    i = 0;
+    while i < 2
+      k = 0;
+      while k < 2
+        k++;
+        ctr++;
+      end
+      i++;
+    end
+    j++;
+  end
+  __printf_assert__ ("%d ", ctr);
+
+  i = 0;
+  while i++ < 2
+    continue
+  end
+  __printf_assert__ ("%d ", i); 
+
+  i = 0;
+  while i++ < 2
+    break
+  end
+  __printf_assert__ ("%d ", i);
+
+  i = 0;
+  while i++ < 2
+  end
+  __printf_assert__ ("%d ", i);
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/bytecode_wordlistcmd.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,25 @@
+function bytecode_wordlistcmd ()
+  foo A B C;
+
+  bar QWE;
+
+  boz
+  boz A
+  boz A B
+end
+
+
+function foo (a,b,c)
+  __printf_assert__ ("%s ", a);
+  __printf_assert__ ("%s ", b);
+  __printf_assert__ ("%s ", c);
+end
+
+function [a b] = bar (c)
+  __printf_assert__ ("%s ", c);
+  a = 1;
+  b = 2;
+end
+
+function boz (a,b,c)
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/cdef_foo.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,21 @@
+classdef cdef_foo < handle
+  properties
+    msg = "";
+    val = 1;
+  end
+  methods
+    function f = cdef_foo(msg)
+        global cdef_foo_ctor_cnt = 0;
+        f.msg = msg;
+        cdef_foo_ctor_cnt++;
+    end
+    function delete (self)
+      global cdef_foo_dtor_cnt = 0;
+      __printf_assert__ ("%d %s ", ++cdef_foo_dtor_cnt, self.msg);
+    endfunction
+    function c = plus (a, b)
+        c = cdef_foo (strcat("sum", a.msg, b.msg));
+        c.val = a.val + b.val;
+    end
+  endmethods
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/inputname_args.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,6 @@
+function inputname_args (arg1, arg2)
+    __printf_assert__ ("%s ", inputname (1, 0));
+    __printf_assert__ ("%s ", inputname (1, 1));
+    __printf_assert__ ("%s ", inputname (2, 0));
+    __printf_assert__ ("%s ", inputname (2, 1));
+end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/just_call_handle_with_arg.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,3 @@
+function a = just_call_handle_with_arg (h, varargin)
+    a = h (varargin{:});
+end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/module.mk	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,48 @@
+compile_TEST_FILES = \
+  %reldir%/bytecode.tst \
+  %reldir%/bytecode_ans.m \
+  %reldir%/bytecode_assign.m \
+  %reldir%/bytecode_binops.m \
+  %reldir%/bytecode_anon_handles.m \
+  %reldir%/bytecode_cdef_use.m \
+  %reldir%/bytecode_cell.m \
+  %reldir%/bytecode_dountil.m \
+  %reldir%/bytecode_end.m \
+  %reldir%/bytecode_errors.m \
+  %reldir%/bytecode_eval_1.m \
+  %reldir%/bytecode_evalin_1.m \
+  %reldir%/bytecode_evalin_2.m \
+  %reldir%/bytecode_for.m \
+  %reldir%/bytecode_global_1.m \
+  %reldir%/bytecode_if.m \
+  %reldir%/bytecode_index_obj.m \
+  %reldir%/bytecode_inputname.m \
+  %reldir%/bytecode_leaks.m \
+  %reldir%/bytecode_matrix.m \
+  %reldir%/bytecode_misc.m \
+  %reldir%/bytecode_multi_assign.m \
+  %reldir%/bytecode_persistant.m \
+  %reldir%/bytecode_range.m \
+  %reldir%/bytecode_return.m \
+  %reldir%/bytecode_struct.m \
+  %reldir%/bytecode_subfuncs.m \
+  %reldir%/bytecode_subsasgn.m \
+  %reldir%/bytecode_switch.m \
+  %reldir%/bytecode_trycatch.m \
+  %reldir%/bytecode_unary.m \
+  %reldir%/bytecode_unwind.m \
+  %reldir%/bytecode_varargin.m \
+  %reldir%/bytecode_varargout.m \
+  %reldir%/bytecode_while.m \
+  %reldir%/bytecode_wordlistcmd.m \
+  %reldir%/cdef_foo.m \
+  %reldir%/inputname_args.m \
+  %reldir%/just_call_handle_with_arg.m \
+  %reldir%/return_isargout.m \
+  %reldir%/shutup_operator_test/@double/display.m \
+  %reldir%/shutup_operator_test/@logical/display.m \
+  %reldir%/shutup_operator_test/bytecode_disp.m \
+  %reldir%/shutup_operator_test/bytecode_disp.tst \
+  %reldir%/wrongname_fn.m
+
+TEST_FILES += $(compile_TEST_FILES)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/return_isargout.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,5 @@
+function [a b c] = return_isargout (n)
+    b = 0;
+    c = 0;
+    a = isargout (n);
+end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/shutup_operator_test/@double/display.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,11 @@
+% For use by bytecode_disp().
+%
+% Overload display
+%
+function display (x)
+    if (inputname(1))
+        __printf_assert__ ("%s = %d ", inputname(1), x);
+    else
+        __printf_assert__ ("%d ", x);
+    end
+end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/shutup_operator_test/@logical/display.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,11 @@
+% For use by bytecode_disp().
+%
+% Overload display
+%
+function display (x)
+    if (inputname(1))
+        __printf_assert__ ("%s = %d ", inputname(1), x);
+    else
+        __printf_assert__ ("%d ", x);
+    end
+end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/shutup_operator_test/bytecode_disp.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,38 @@
+function bytecode_disp()
+  %  int8 type's display is overloaded with a __printf_assert__
+  1               % "ans = 1"
+  print_dot;
+  2 + 3           % "ans = 5"
+  print_dot;
+  0;              %
+  0 + 0;          %
+  print_dot;
+  ~4              % "ans = 0"
+  print_dot;
+  2^3             % "ans = 8"
+  print_dot       %
+  
+  if 2
+    3             % "ans = 3"
+  end
+  print_dot;
+  x = 4 - 1       % "x = 3"
+ 
+  print_dot;
+  [x, y] = deal (1,2) % "x = 1" "y = 2"
+  print_dot;
+  [x, ~] = deal (1,2) % "x = 1"
+  print_dot;
+  % If all lvalues are black holes, nothing is printed
+  [~, ~] = deal (1,2) %
+  print_dot;
+  [x, ~, ~] = deal (1,2, 3) % "x = 1"
+  print_dot;
+  [~, y, ~] = deal (1,2, 3) % "y = 2"
+  print_dot;
+  x
+end
+
+function print_dot()
+  __printf_assert__(". ");
+end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/shutup_operator_test/bytecode_disp.tst	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,18 @@
+## Test display due to no ";" at eol
+##
+## We are overloading display for double so we place this test
+## in its own folder to not mess double up for the other 
+## tests.
+
+%!test
+%! % Overloading of class-methods seems to stick so we need to clear them since we overload
+%! % double's display. Is this a bug ???
+%! clear classes
+%! key = "ans = 1 . ans = 5 . . ans = 0 . ans = 8 . ans = 3 . x = 3 . x = 1 y = 2 . x = 1 . . x = 1 . y = 2 . x = 1 ";
+%! __compile bytecode_disp clear;
+%! bytecode_disp;
+%! assert (__prog_output_assert__ (key));
+%!
+%! assert (__compile ("bytecode_disp"));
+%! bytecode_disp;
+%! assert (__prog_output_assert__ (key));
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/compile/wrongname_fn.m	Mon Jun 19 16:35:32 2023 -0400
@@ -0,0 +1,3 @@
+function a = rightname_fn (b)
+  a = b + 1;
+end
\ No newline at end of file