Skip to content

Commit

Permalink
Adding more tests and updating readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
cdiggins committed Jan 3, 2018
1 parent 4947b3e commit fc9f016
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 42 deletions.
31 changes: 30 additions & 1 deletion cat-test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cat-test.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 34 additions & 1 deletion cat-test.ts
Expand Up @@ -15,6 +15,9 @@ function printEnvironment(ce : cat.CatEnvironment) {
}

function testEvaluator() {
console.log("=================");
console.log("Testing evaluator");
console.log("=================");
var ce = new cat.CatEvaluator();
ce.trace = true;
ce.eval("6 7 dup mul sub");
Expand Down Expand Up @@ -67,7 +70,7 @@ function outputDefinitions() {
console.log("Core Stack Operations")
console.log('=====================');
for (var k in ce.primOps)
outputInstruction(ce.getInstruction(k));
console.log(k + " : " + ce.primOps[k]);

console.log('===================');
console.log("Primitive Functions")
Expand All @@ -94,9 +97,39 @@ function outputGrammar() {
console.log(cat.astSchemaString());
}

function outputFormalTypes() {
var ce = new cat.CatEnvironment();

console.log('=======================');
console.log("Core Stack Formal Types")
console.log('=======================');
for (var k in ce.primOps) {
var i = ce.getInstruction(k);
console.log(k + " : " + i.type.toString());
}

console.log('=============================');
console.log("Standard Library Formal Types")
console.log('=============================');
for (var k in ce.stdOps) {
var i = ce.getInstruction(k);
var t = ti.alphabetizeVarNames(i.type);
console.log(k + " : " + t);
}
}

function testTypes() {
var ce = new cat.CatEvaluator();
var i = ce.env.addDefinition("test", "quote dup apply");
console.log("Type of " + i.name + " : " + i.type);
ce.eval("10 test");
}

outputGrammar();
outputDefinitions();
outputFormalTypes();
testEvaluator();
testTypes();

declare var process : any;
process.exit();
1 change: 1 addition & 0 deletions cat.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cat.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cat.ts
Expand Up @@ -9,6 +9,7 @@ import { Myna as m } from "./node_modules/myna-parser/myna";
// A type-inference library: https://github.com/cdiggins/type-inference
import { TypeInference as ti } from "./node_modules/type-inference/type_inference";

// This is a full rewrite of the Cat language (which was originally in C#) written in TypeScript
export module CatLanguage
{
// Defines a Myna grammar for parsing Cat programs and types
Expand Down

0 comments on commit fc9f016

Please sign in to comment.