created mirror

This commit is contained in:
whatever
2026-09-14 20:19:29 -04:00
commit 6764738d92
600 changed files with 87187 additions and 0 deletions

2
Modules/test/README Normal file
View File

@@ -0,0 +1,2 @@
Some classes for testing various things. Mostly useful only for
developers.

View File

@@ -0,0 +1,100 @@
/*
TestClang1.java
*
* Copyright (c) 2000, Ted Nelson and Tuomas Lukka
*
* You may use and distribute under the terms of either the GNU Lesser
* General Public License, either version 2 of the license or,
* at your choice, any later version. Alternatively, you may use and
* distribute under the terms of the XPL.
*
* See the LICENSE.lgpl and LICENSE.xpl files for the specific terms of
* the licenses.
*
* This software 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 README
* file for more details.
*
*/
/*
* Written by Tuomas Lukka
*/
package org.gzigzag.module;
import org.gzigzag.*;
import org.gzigzag.clang.*;
import java.util.*;
import java.awt.*;
class ELIFJSEF {
}
/** A small tester for Clang.
*/
public class TestClang1 {
public static final String rcsid = "$Id: TestClang1.java,v 1.9 2000/10/18 14:35:32 tjl Exp $";
public static final boolean dbg = true;
static final void p(String s) { if(dbg) System.out.println(s); }
static final void pa(String s) { System.out.println(s); }
static public ZZModule module = new ZZModule() {
public void action(String id,
ZZCell code,
ZZCell target,
ZZView view, ZZView cview, String key, Point pt, ZZScene xi) {
ZZCell viewCursor = ZZCursorReal.get(view.getViewcell());
p("TESTCLANG ACTION!");
if(id.equals("1")) {
test1(viewCursor);
} else {
pa("UNKNOWN TESTCLANG1 COMMAND "+id);
}
p("TESTCLANG ACTION RETURNS!");
}
};
static void test1(ZZCell curs) {
ZZClang1 clang = new ZZClang1();
ZZClangOp[] ops = ZZClangOps.getOps1();
for(int i = 0; i < ops.length; i++)
clang.addOp(ops[i]);
ZZCell main = curs.N("d.2", 1);
// Goal of script: connect these two.
ZZCell c1 = main.N("d.1", 1);
c1.setText("c1");
ZZCell c2 = c1.N("d.1", 1);
c1.setText("c2");
ZZCell func = main.N("d.2", 1);
func = func.N("d.1", 1);
func.setText("func");
ZZCell par = func.N("d.1", 1);
par.setText("c");
ZZCell cmd = func.N("d.2", 1);
cmd.setText("connect");
ZZCell param = cmd.N("d.1", 1);
par.insert("d.clone", 1, param);
param = param.N("d.1", 1);
param.setText("d.2");
param = param.N("d.1", 1);
par.insert("d.clone", 1, param);
param = param.N("d.2", 1);
param.setText("step");
param = param.N("d.1", 1);
param.setText("d.1");
param = param.N("d.1", 1);
param.setText("1");
p("TESTCLANG CLANGEXEC!");
// clang.exec(func, null, new ZZCell[] { c1 });
}
}

View File

@@ -0,0 +1,55 @@
/*
TestHuge.java
*
* Copyright (c) 2000, Ted Nelson and Tuomas Lukka
*
* You may use and distribute under the terms of either the GNU Lesser
* General Public License, either version 2 of the license or,
* at your choice, any later version. Alternatively, you may use and
* distribute under the terms of the XPL.
*
* See the LICENSE.lgpl and LICENSE.xpl files for the specific terms of
* the licenses.
*
* This software 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 README
* file for more details.
*
*/
/*
* Written by Tuomas Lukka
*/
package org.gzigzag.module;
import org.gzigzag.*;
import java.util.*;
import java.awt.*;
public class TestHuge {
public static final String rcsid = "$Id: TestHuge.java,v 1.4 2000/10/18 14:35:32 tjl Exp $";
static public ZZModule module = new ZZModule() {
public void action(String id, ZZCell code,
ZZCell target,
ZZView v, ZZView cv,
String key, Point pt,
ZZScene xi) {
if(id.equals("ADDTREE")) {
ZZCell h = target.getHomeCell();
h = h.h("d.1", 1);
ZZCell n = null;
int nth = 1;
for(; h != null; h=h.s("d.2", 1)) {
ZZCell m = h.N("d.1", 1);
m.setText(""+(nth++));
if(n != null) n.connect("d.2", 1, m);
n = m.N("d.2", 1);
n.setText(""+(nth++));
}
}
}
};
}

210
Modules/test/TestUndo.java Normal file
View File

@@ -0,0 +1,210 @@
/*
TestUndo.java
*
* Copyright (c) 2000, Ted Nelson and Tuomas Lukka
*
* You may use and distribute under the terms of either the GNU Lesser
* General Public License, either version 2 of the license or,
* at your choice, any later version. Alternatively, you may use and
* distribute under the terms of the XPL.
*
* See the LICENSE.lgpl and LICENSE.xpl files for the specific terms of
* the licenses.
*
* This software 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 README
* file for more details.
*
*/
/*
* Written by Tuomas Lukka
*/
package org.gzigzag;
import java.io.*;
public class TestUndo {
String rcsid = "$Id: TestUndo.java,v 1.8 2000/11/30 08:44:33 ajk Exp $";
public static final boolean dbg = true;
final static void p(String s) { if(dbg) System.out.println(s); }
/*
static void printdim(ZZDimension d, int max) {
for(int i=1; i<=max; i++) {
p(i+"\t+"+ d.s(""+i, 1, null)+
"\t-"+ d.s(""+i, -1, null));
}
p("");
}
static String ct2str(Object o) {
if(o instanceof String)
return "'"+o+"'";
else if(o instanceof Span)
return "SPAN: "+o;
else if(o == null)
return "null";
throw new Error("Invalid content "+o);
}
static void printct(ContentStore st, int max) {
for(int i=1; i<=max; i++) {
p(i+"\t"+ct2str(st.get(""+i)));
}
p("");
}
public static void main(String[] argv) {
{
ZZCacheDimension d = new ZZCacheDimension();
UndoList ul = new UndoList(42);
d.setUndoList(ul);
ZZDimStorer pstor = new ZZDimStorer() {
public void storeConnect(String a, String b) {
p("Storeconn: "+a+" "+b);
}
public void storeDisconnect(String a, int dir) {
p("Storedisc: "+a+" "+dir);
}
};
ContentStorer cstor = new ContentStorer() {
public void putContent(String id, Object ct) {
p("StoreCont: "+id+" "+ct2str(ct)+"");
}
};
d.connect("1", "2");
d.connect("3", "4");
ul.stamp();
printdim(d, 4);
ul.undo();
p("undo:");
printdim(d, 4);
ul.redo();
p("redo:");
printdim(d, 4);
p(" Next, more difficult test.");
d.disconnect("1", 1);
d.connect("1", "3");
ul.stamp();
printdim(d, 4);
ul.undo();
p("undo:");
printdim(d, 4);
ul.undo();
p("undo:");
printdim(d, 4);
ul.redo();
p("redo:");
printdim(d, 4);
ul.redo();
p("redo:");
printdim(d, 4);
p("Next, whether commit does the right ops...");
d.startCommit();
ul.commit();
d.endCommit(pstor);
p("Commit finished");
p("More edits");
d.disconnect("3", 1);
d.connect("2", "4");
printdim(d, 4);
p("Commit ops...");
d.startCommit();
ul.commit();
d.endCommit(pstor);
p("Commit finished");
p("Next, we'll test the simple file format.");
SimpleDimFile f = new SimpleDimFile();
ByteArrayOutputStream bo = new ByteArrayOutputStream();
f.startWrite(new DataOutputStream(bo));
f.storeConnect("Foo", "Bar");
f.storeConnect("1", "2");
f.storeDisconnect("a", 1);
f.storeDisconnect("b", -1);
f.storeDisconnect("3", 1);
f.endWrite();
byte[] bytes = bo.toByteArray();
bo.reset();
p("Wrote ops. Now read.");
// f.read(new DataInputStream(new ByteArrayInputStream(bytes)), pstor);
p("Finally, test the content storage as well");
ZZCacheContentStore ccs = new ZZCacheContentStore();
ccs.setUndoList(ul);
ul.stamp();
ccs.put("1", "foo");
ccs.put("2", "bar");
ccs.put("3", Span.parse("1.5:1.8"));
ul.stamp();
ccs.put("2", "txt");
ul.stamp();
printct(ccs, 4);
ul.undo();
p("Undo: ");
printct(ccs, 4);
ul.undo();
p("Undo: ");
printct(ccs, 4);
ul.redo();
p("Redo: ");
printct(ccs, 4);
ul.redo();
p("Redo: ");
printct(ccs, 4);
SimpleContentFile cf = new SimpleContentFile();
cf.startWrite(new DataOutputStream(bo));
cf.putContent("A", "FOO");
cf.putContent("B", "bar");
cf.putContent("C", Span.parse("1.5:1.8"));
cf.endWrite();
bytes = bo.toByteArray();
bo.reset();
p("Wrote txts; read:");
// cf.read(new DataInputStream(new ByteArrayInputStream(bytes)), cstor);
}
}
*/
}