package terse.vm;

import terse.vm.Terp;
import terse.vm.Terp.Frame;
import junit.framework.TestCase;

public class TerpTest extends TestCase {
	Terp t;
	Frame f;

	public TerpTest(String arg0) {
		super(arg0);
	}

	public void testTerpSimple() {
		new Terp.TestingTerp(false, "__ExprTest__", "");
	}

	public void testTerpWithPrelude() {
		new Terp.TestingTerp(true, "__TerpTest__", "");
		;
	}

	public void testStrs() {
		String[] a = Static.strs("one", "two");
		String[] b = Static.append(a, "three");
		assertEquals(3, b.length);
		assertEquals("one", b[0]);
		assertEquals("two", b[1]);
		assertEquals("three", b[2]);
	}

	public void testhtmlEscape() {
		assertEquals("it&quot;s &lt;pb&gt; &amp; J.\n",
				Static.htmlEscape("it\"s <pb> & J.\n"));
	}

	public void testSplitNonEmpty() {
		assertEquals("foo", Static.splitNonEmpty("foo", '/')[0]);
		assertEquals("foo", Static.splitNonEmpty("/foo", '/')[0]);
		assertEquals("foo", Static.splitNonEmpty("foo/", '/')[0]);
		assertEquals("foo", Static.splitNonEmpty("//foo", '/')[0]);
		assertEquals("foo", Static.splitNonEmpty("foo//", '/')[0]);
		assertEquals("foo", Static.splitNonEmpty("/foo//bar//", '/')[0]);
		assertEquals("foo", Static.splitNonEmpty("foo/bar", '/')[0]);
		assertEquals("bar", Static.splitNonEmpty("/foo//bar//", '/')[1]);
		assertEquals("bar", Static.splitNonEmpty("foo/bar", '/')[1]);
	}
}
