#SRC: JCON

procedure main()
   local skips, vowels, uppers

   write(any('ab', "1234ab", 0, 7) | "fail")
   write(any('ab', "1234ab", 7, 0) | "fail")
   write(any('ab', "1234ab", 6, 0) | "fail")
   write(any('ab', "1234ab", 6) | "fail")
   write(any('ab', "1234ab") | "fail")
   "1234ab" ? write(any('ab', "1234ab") | "fail")
   "1234ab" ? write(any('ab') | "fail")
   "1234ab" ? { &pos := 6 & write(any('ab') | "fail") }
   write()

   write(many('ab', "ababac") | "fail")
   write(many('ab', "ababab") | "fail")
   write(many('ab', "cababab") | "fail")
   write()

   write(match("ab", "ababab") | "fail")
   write(match("ab", "bbabab") | "fail")
   write(match("ab", "ab") | "fail")
   write(match("ab", "a") | "fail")
   write()

   every write(find("ab", "ababab"|"ababa"|"ab"|"a"|"") | "done")
   write()

   every write(upto('ab', "abccab"|"cbabc"|"ab"|"a"|"") | "done")
   write()

   "123456" ? write(move(1), " ", move(2))
   "123456" ? { write(move(1)); write(move(2)); write(move(3));
		write(move(4)); write(move(-4))}
   write()

   "123456" ? write(tab(1), " ", tab(2))
   "123456" ? { write(tab(2)); write(tab(4)); write(tab(-1)); write(tab(0)); }
   "123456" ? { write(tab(4)); write(tab(1)); write(tab(3)); }
   write()

   every write("-35" ? bal('-'))
   every write("((2*x)+3)+(5*y)" ? bal('+'))
   every write("[+,[2,3]],[*,[5,10]]" ? bal(',', '[', ']'))
   write()

   "12345" ? { write(pos(1)); write(pos(-5)); write(pos(3)|"fail"); }
   write()

   "12345" ? { write(="123" | "fail") }
   "12345" ? { tab(2); write(="123" | "fail") }
   "12345" ? { tab(2); write(="23" | "fail") }

   # test upto, including some chars with 8th bit set
   write()
   skips := '\x00\x0f\x1e-<KZix\x87\x96\xa5\xb4\xc3\xd2\xe1\xf0\xff'
   vowels := 'aeoiuAEIOU'
   uppers := &cset -- &ascii
   &ascii ? {
      every writes(" ", "ascii?skips" | upto(skips) | "\n")
      every writes(" ", "ascii?vowls" | upto(vowels) | "\n")
      }
   &letters ? {
      every writes(" ", "letts?skips" | upto(skips) | "\n")
      every writes(" ", "letts?vowls" | upto(vowels) | "\n")
      }
   vowels ? {
      every writes(" ", "vowls?skips" | upto(skips) | "\n")
      every writes(" ", "vowls?letts" | upto(&letters) | "\n")
      every writes(" ", "vowls?ascii" | upto(&ascii) | "\n")
      }
   skips ? {
      every writes(" ", "skips?vowls" | upto(vowels) | "\n")
      every writes(" ", "skips?letts" | upto(&letters) | "\n")
      every writes(" ", "skips?ascii" | upto(&ascii) | "\n")
      every writes(" ", "skips?upprs" | upto(uppers) | "\n")
      every writes(" ", "skips?skips" | upto(skips) | "\n")
      }
   uppers ? {
      every writes(" ", "upprs?ascii" | upto(&ascii) | "\n")
      every writes(" ", "upprs?skips" | upto(skips) | "\n")
      }
end
