Skip to content

Commit

Permalink
chore: Refactor, set up tests using dropecho.testing.
Browse files Browse the repository at this point in the history
Remove old munit.
Set up python build.
  • Loading branch information
vantreeseba committed Oct 27, 2024
1 parent d955af7 commit d1144f3
Show file tree
Hide file tree
Showing 15 changed files with 304 additions and 457 deletions.
6 changes: 0 additions & 6 deletions .munit

This file was deleted.

2 changes: 1 addition & 1 deletion .vim/coc-settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"haxe.hxml": "test.hxml"
"haxe.hxml": "build.hxml"
}
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
This code is licensed under the MIT License:

> Copyright (c) 2016: Martin O'Leary
> Copyright (c) 2016: Benjamin Van Treese
>
> Permission is hereby granted, free of charge, to any person obtaining
> a copy of this software and associated documentation files (the
Expand Down
2 changes: 2 additions & 0 deletions build.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ targets/js-esm.hxml
--next
targets/cs.hxml
--next
targets/python.hxml
--next
targets/docs.hxml
5 changes: 3 additions & 2 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
},
"license": "MIT",
"scripts": {
"install": "lix download",
"build": "npm run clean && haxe build.hxml && npm run docs:cp_js",
"docs:cp_js": "cp dist/js/cjs/index.cjs docs/storygen.js",
"test": "haxelib run munit t",
"test": "haxelib run dropecho.testing",
"clean": "rm -rf dist && rm -rf artifacts"
},
"devDependencies": {
Expand Down
45 changes: 19 additions & 26 deletions test.hxml
Original file line number Diff line number Diff line change
@@ -1,36 +1,29 @@
# CSharp
-main TestMain
-lib dropecho.interop
-lib munit
-lib hamcrest
-lib seedyrng

-cp src
-cp test

-D dce=no

-D dll_import
-D no-root
-cs build/cs_test
--next

## JavaScript NodeJS
-main TestMain
-lib dropecho.interop
-lib munit
-lib hamcrest
-lib seedyrng
-lib dropecho.interop
-lib dropecho.testing
-lib utest

-cp src
-cp test

-D dce=no
--each

# --next
-lib hxnodejs
-js build/js_test.cjs
-D js-es=6
-js artifacts/js_test.cjs

# --next
# -lib hxnodejs
# -lib genes
# -js artifacts/js_esm_test/test.js
#
# --next
# -D net-ver=40
# -cs artifacts/cs_test

# --next
# -python artifacts/python_test

# ## HashLink
# --next
# -hl build/hl_test.hl
# -neko artifacts/neko_test.n
74 changes: 0 additions & 74 deletions test/TestMain.hx

This file was deleted.

23 changes: 0 additions & 23 deletions test/TestSuite.hx

This file was deleted.

40 changes: 17 additions & 23 deletions test/storygen/FunctionsTest.hx → test/storygen/Functions_Tests.hx
Original file line number Diff line number Diff line change
@@ -1,63 +1,57 @@
package storygen;

import dropecho.storygen.Generator.WordList;
import massive.munit.Assert;
import dropecho.storygen.*;
import utest.Assert;

class FunctionsTest {
class Functions_Tests extends utest.Test {
var generator:Generator;

@Before
public function setup() {
var config = ["test" => (['a'] : WordList), "test2" => (['b'] : WordList)];
generator = new Generator(config);
}

@Test
public function repeat() {
public function test_repeat() {
var repeat = Functions.get("repeat");
Assert.isNotNull(random);
Assert.notNull(repeat);

var out = repeat(generator, ["test2", "4", "4"]);
Assert.areEqual("b b b b", out);
Assert.equals("b b b b", out);
}

@Test
public function random() {
public function test_random() {
var random = Functions.get("random");
Assert.isNotNull(random);
Assert.notNull(random);

var out = random(generator, ["1", "1"]);
Assert.areEqual("1", out);
Assert.equals("1", out);
}

@Test
public function switch_test() {
public function test_switch_test() {
generator.memory.set("bar", "test2");
var sw = Functions.get("switch");
Assert.isNotNull(sw);
Assert.notNull(sw);

var out = sw(generator, ["bar", "test=>test", "test2=>test2"]);
Assert.areEqual("#test2#", out);
Assert.equals("#test2#", out);
}

@Test
public function swit_to_null() {
public function test_switch_to_null() {
generator.memory.set("bar", "test2");
var sw = Functions.get("switch");
Assert.isNotNull(sw);
Assert.notNull(sw);

var out = sw(generator, ["bar", "test=>test"]);
Assert.areEqual("", out);
Assert.equals("", out);
}

@Test
public function switch_test_default() {
public function test_switch_test_default() {
generator.memory.set("bar", "test2");
var sw = Functions.get("switch");
Assert.isNotNull(sw);
Assert.notNull(sw);

var out = sw(generator, ["bar", "test=>test", "_=>default"]);
Assert.areEqual("default", out);
Assert.equals("default", out);
}
}
Loading

0 comments on commit d1144f3

Please sign in to comment.