Skip to content

Commit

Permalink
cleaned up test logs
Browse files Browse the repository at this point in the history
  • Loading branch information
AjaniBilby committed May 29, 2024
1 parent fad3e20 commit 344ccb9
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build:compiler": "deno compile --output salient.exe -A ./source/cli.ts",
"test": "run-s test:*",
"test:deno": "deno test",
"test:reflect": "npm run sa-test ./tests/reflective",
"test:reflect": "npm run sa-test ./tests",
"cli": "deno run -A ./source/cli.ts",
"sa-test": "deno run -A ./source/cli.ts test",
"compile": "deno run -A ./source/cli.ts compile"
Expand Down
6 changes: 3 additions & 3 deletions source/compiler/package.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dirname, relative } from "https://deno.land/[email protected]/path/mod.ts";
import { relative } from "https://deno.land/[email protected]/path/mod.ts";

import type Project from "~/compiler/project.ts";
import { File } from "~/compiler/file.ts"
Expand All @@ -11,13 +11,13 @@ export default class Package {

failed: boolean;

constructor(project: Project, base: string, name: string = "~") {
constructor(project: Project, base: string, name = "~") {
this.project = project;
this.failed = false;
this.files = [];

this.name = name;
this.cwd = dirname(base);
this.cwd = base;
}

import(filePath: string) {
Expand Down
17 changes: 8 additions & 9 deletions source/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import TestCase from "~/compiler/test-case.ts";
import Package from "~/compiler/package.ts";
import Project from "~/compiler/project.ts";



export async function Test() {
// Determine all of the files to test
const targets = Deno.args.length > 1
Expand Down Expand Up @@ -37,7 +35,8 @@ export async function Test() {

const index = new Array<TestCase>();

console.log("Compiling...");
console.log("Compilation");
const compStart = Date.now();
for (const path of files.values()) {
const file = mainPck.import(path);

Expand All @@ -48,10 +47,10 @@ export async function Test() {
index.push(test);
}
}
const compEnd = Date.now();

if (project.failed) Deno.exit(1);


console.log(` Found and compiled ${index.length} test cases ${colors.gray(`(${compEnd-compStart}ms)`)}`)


// Run all of the tests
Expand All @@ -61,13 +60,13 @@ export async function Test() {
let fails = 0;
const exports = instance.exports;
let prev = "";
const start = Date.now();
const execStart = Date.now();
for (let i=0; i<index.length; i++) {
const test = index[i];

if (prev !== test.file.name) {
prev = test.file.name;
console.log("\n"+colors.gray(prev));
console.log("\n"+colors.gray(prev.replaceAll('\\', '/')));
}

const func = exports[`test${i}`];
Expand All @@ -84,12 +83,12 @@ export async function Test() {
);
if (!result) fails++;
}
const end = Date.now();
const execEnd = Date.now();

console.log(`\n ${fails == 0 ? colors.green("ok") : colors.red("FAIL")}`
+ ` | ${index.length-fails} passed`
+ ` | ${fails} failed`
+ colors.gray(` (${end-start}ms)`)
+ colors.gray(` (${execEnd-execStart}ms)`)
);
}

Expand Down
1 change: 1 addition & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!*.test.sa
File renamed without changes.
6 changes: 3 additions & 3 deletions tests/reflective/numeric.test.sa → tests/numeric.test.sa
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test "Order of operations: Remainder" {
// if ( 10.0 - ( 3.0 / 2.0 ) - 8.0 != 10.0 - 3.0 / 2.0 - 8.0 ) {
// return 20;
// };
if ( 10.0 - ( 3.0 / 2.0 ) - 8.0 != 10.0 - 3.0 / 2.0 - 8.0 ) {
return false;
};

// (-2.5 % 2.0) * -3.0 == 10.0 - ((1.0 / 2.0) % 10.0) - 8.0;
// 1.5 == 1.5
Expand Down
1 change: 0 additions & 1 deletion tests/reflective/.gitignore

This file was deleted.

0 comments on commit 344ccb9

Please sign in to comment.