From c3691e7169c4e58682670b7f7d8120e56db9f904 Mon Sep 17 00:00:00 2001 From: Max Richter Date: Thu, 18 Apr 2024 00:21:01 +0200 Subject: [PATCH] fix: some test --- nodes/max/plantarium/stem/src/lib.rs | 2 +- nodes/max/plantarium/triangle/src/lib.rs | 2 +- packages/types/package.json | 3 --- packages/utils/package.json | 6 +++++- packages/utils/src/encoding.test.ts | 2 +- packages/utils/src/flatTree.test.ts | 2 +- packages/utils/src/geometry/extrude_path.rs | 2 -- packages/utils/src/geometry/mod.rs | 1 - packages/utils/src/tree.rs | 8 +++++--- packages/utils/vite.config.ts | 4 ++++ pnpm-lock.yaml | 11 +++++++++++ 11 files changed, 29 insertions(+), 14 deletions(-) create mode 100644 packages/utils/vite.config.ts diff --git a/nodes/max/plantarium/stem/src/lib.rs b/nodes/max/plantarium/stem/src/lib.rs index f40dde2..9448582 100644 --- a/nodes/max/plantarium/stem/src/lib.rs +++ b/nodes/max/plantarium/stem/src/lib.rs @@ -1,5 +1,5 @@ use macros::include_definition_file; -use utils::{decode_float, evaluate_args, get_args, log, set_panic_hook, wrap_arg}; +use utils::{decode_float, evaluate_args, get_args, set_panic_hook, wrap_arg}; use wasm_bindgen::prelude::*; include_definition_file!("src/input.json"); diff --git a/nodes/max/plantarium/triangle/src/lib.rs b/nodes/max/plantarium/triangle/src/lib.rs index cdbf1db..3af6ada 100644 --- a/nodes/max/plantarium/triangle/src/lib.rs +++ b/nodes/max/plantarium/triangle/src/lib.rs @@ -1,5 +1,5 @@ use macros::include_definition_file; -use utils::{concat_args, decode_float, encode_float, wrap_arg}; +use utils::{decode_float, encode_float, wrap_arg}; use wasm_bindgen::prelude::*; use web_sys::console; diff --git a/packages/types/package.json b/packages/types/package.json index fe06314..94771ac 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -3,9 +3,6 @@ "version": "1.0.0", "description": "", "main": "index.ts", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, "keywords": [], "author": "", "license": "ISC" diff --git a/packages/utils/package.json b/packages/utils/package.json index 56f51a3..c6619e8 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -4,12 +4,16 @@ "description": "", "main": "src/index.ts", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "vitest" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "@nodes/types": "link:../types" + }, + "devDependencies": { + "vite": "^5.2.9", + "vitest": "^1.5.0" } } diff --git a/packages/utils/src/encoding.test.ts b/packages/utils/src/encoding.test.ts index 8813c61..eff8bc6 100644 --- a/packages/utils/src/encoding.test.ts +++ b/packages/utils/src/encoding.test.ts @@ -1,5 +1,5 @@ import { test, expect } from "vitest" -import { encodeFloat, decodeFloat } from "./encode" +import { encodeFloat, decodeFloat } from "./encoding" test("encode_float", () => { const input = 1.23; diff --git a/packages/utils/src/flatTree.test.ts b/packages/utils/src/flatTree.test.ts index c0ff6a3..c6d020a 100644 --- a/packages/utils/src/flatTree.test.ts +++ b/packages/utils/src/flatTree.test.ts @@ -1,5 +1,5 @@ import { expect, test } from 'vitest' -import { decode, encode, concat_encoded } from './flat_tree' +import { decode, encode, concat_encoded } from './flatTree' test("it correctly concats nested arrays", () => { diff --git a/packages/utils/src/geometry/extrude_path.rs b/packages/utils/src/geometry/extrude_path.rs index fad5ea2..27e3301 100644 --- a/packages/utils/src/geometry/extrude_path.rs +++ b/packages/utils/src/geometry/extrude_path.rs @@ -1,5 +1,3 @@ -use crate::log; - use super::create_empty_geometry; use glam::{Mat4, Quat, Vec3}; diff --git a/packages/utils/src/geometry/mod.rs b/packages/utils/src/geometry/mod.rs index db9300a..c499d2f 100644 --- a/packages/utils/src/geometry/mod.rs +++ b/packages/utils/src/geometry/mod.rs @@ -20,7 +20,6 @@ pub fn create_empty_geometry(vertex_amount: usize, face_amount: usize) -> Vec = vec![0; amount]; vec[0] = 0; // opening bracket diff --git a/packages/utils/src/tree.rs b/packages/utils/src/tree.rs index f602fce..c564cba 100644 --- a/packages/utils/src/tree.rs +++ b/packages/utils/src/tree.rs @@ -82,7 +82,7 @@ pub fn concat_args(mut data: Vec>) -> Vec { // Add [1, 1] at the end // result.push(1); - // result.push(1); + result.push(1); result } @@ -144,8 +144,10 @@ mod tests { use super::*; #[test] - fn test_resursive_evaluation() { - let input = vec![0, 3, 0, 0, 0, 7, 0, 2, 0, 128, 0, 128, 1, 6, 0, 128]; + fn test_recursive_evaluation() { + let input = vec![ + 0, 3, 0, 0, 0, 5, 0, 2, 1073741824, 1073741824, 1, 5, 1073741824, + ]; // this is an encoded version of a math node that multiplies 2 * 2 // and another math node that adds 2 to that result // the numbers are f32 floats encoded as two i32's diff --git a/packages/utils/vite.config.ts b/packages/utils/vite.config.ts new file mode 100644 index 0000000..a72c03b --- /dev/null +++ b/packages/utils/vite.config.ts @@ -0,0 +1,4 @@ +import { defineConfig } from 'vite' + +export default defineConfig({ +}) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a4c5d83..c760499 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -106,6 +106,10 @@ importers: nodes/max/plantarium/array/pkg: {} + nodes/max/plantarium/box: {} + + nodes/max/plantarium/box/pkg: {} + nodes/max/plantarium/float: {} nodes/max/plantarium/float/pkg: {} @@ -260,6 +264,13 @@ importers: '@nodes/types': specifier: link:../types version: link:../types + devDependencies: + vite: + specifier: ^5.2.9 + version: 5.2.9 + vitest: + specifier: ^1.5.0 + version: 1.5.0 packages: