fix: some test

This commit is contained in:
max_richter 2024-04-18 00:21:01 +02:00
parent 2edd22136f
commit c3691e7169
11 changed files with 29 additions and 14 deletions

View File

@ -1,5 +1,5 @@
use macros::include_definition_file; 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::*; use wasm_bindgen::prelude::*;
include_definition_file!("src/input.json"); include_definition_file!("src/input.json");

View File

@ -1,5 +1,5 @@
use macros::include_definition_file; 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 wasm_bindgen::prelude::*;
use web_sys::console; use web_sys::console;

View File

@ -3,9 +3,6 @@
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "",
"main": "index.ts", "main": "index.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [], "keywords": [],
"author": "", "author": "",
"license": "ISC" "license": "ISC"

View File

@ -4,12 +4,16 @@
"description": "", "description": "",
"main": "src/index.ts", "main": "src/index.ts",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "vitest"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@nodes/types": "link:../types" "@nodes/types": "link:../types"
},
"devDependencies": {
"vite": "^5.2.9",
"vitest": "^1.5.0"
} }
} }

View File

@ -1,5 +1,5 @@
import { test, expect } from "vitest" import { test, expect } from "vitest"
import { encodeFloat, decodeFloat } from "./encode" import { encodeFloat, decodeFloat } from "./encoding"
test("encode_float", () => { test("encode_float", () => {
const input = 1.23; const input = 1.23;

View File

@ -1,5 +1,5 @@
import { expect, test } from 'vitest' 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", () => { test("it correctly concats nested arrays", () => {

View File

@ -1,5 +1,3 @@
use crate::log;
use super::create_empty_geometry; use super::create_empty_geometry;
use glam::{Mat4, Quat, Vec3}; use glam::{Mat4, Quat, Vec3};

View File

@ -21,7 +21,6 @@ pub fn create_empty_geometry(vertex_amount: usize, face_amount: usize) -> Vec<i3
+ vertex_amount * 3 // normals + vertex_amount * 3 // normals
+ face_amount * 3; // faces + face_amount * 3; // faces
let mut vec: Vec<i32> = vec![0; amount]; let mut vec: Vec<i32> = vec![0; amount];
vec[0] = 0; // opening bracket vec[0] = 0; // opening bracket
vec[1] = amount as i32 - 2; // opening bracket vec[1] = amount as i32 - 2; // opening bracket

View File

@ -82,7 +82,7 @@ pub fn concat_args(mut data: Vec<Vec<i32>>) -> Vec<i32> {
// Add [1, 1] at the end // Add [1, 1] at the end
// result.push(1); // result.push(1);
// result.push(1); result.push(1);
result result
} }
@ -144,8 +144,10 @@ mod tests {
use super::*; use super::*;
#[test] #[test]
fn test_resursive_evaluation() { fn test_recursive_evaluation() {
let input = vec![0, 3, 0, 0, 0, 7, 0, 2, 0, 128, 0, 128, 1, 6, 0, 128]; 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 // this is an encoded version of a math node that multiplies 2 * 2
// and another math node that adds 2 to that result // and another math node that adds 2 to that result
// the numbers are f32 floats encoded as two i32's // the numbers are f32 floats encoded as two i32's

View File

@ -0,0 +1,4 @@
import { defineConfig } from 'vite'
export default defineConfig({
})

View File

@ -106,6 +106,10 @@ importers:
nodes/max/plantarium/array/pkg: {} nodes/max/plantarium/array/pkg: {}
nodes/max/plantarium/box: {}
nodes/max/plantarium/box/pkg: {}
nodes/max/plantarium/float: {} nodes/max/plantarium/float: {}
nodes/max/plantarium/float/pkg: {} nodes/max/plantarium/float/pkg: {}
@ -260,6 +264,13 @@ importers:
'@nodes/types': '@nodes/types':
specifier: link:../types specifier: link:../types
version: 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: packages: