From f049e1f9fb0067fdff6fa571af431e000e30d274 Mon Sep 17 00:00:00 2001 From: ValKmjolnir Date: Sat, 30 Apr 2022 20:00:15 +0800 Subject: [PATCH] add test file diff.nas --- makefile | 1 + nasal_builtin.h | 2 +- test/calc.nas | 1 + test/scalar.nas | 8 +++++++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/makefile b/makefile index c514751..c4b8bff 100644 --- a/makefile +++ b/makefile @@ -16,6 +16,7 @@ test:nasal @ ./nasal -op -e -d test/calc.nas @ ./nasal -op -e test/choice.nas @ ./nasal -op -e test/class.nas + @ ./nasal -op -e test/diff.nas -@ ./nasal -op -d test/exception.nas @ ./nasal -op -t -d test/fib.nas @ ./nasal -op -e test/filesystem.nas diff --git a/nasal_builtin.h b/nasal_builtin.h index 4830bab..22d5626 100644 --- a/nasal_builtin.h +++ b/nasal_builtin.h @@ -424,7 +424,7 @@ nasal_ref builtin_str(nasal_ref* local,nasal_gc& gc) nasal_ref builtin_size(nasal_ref* local,nasal_gc& gc) { nasal_ref val=local[1]; - double num; + double num=0; switch(val.type) { case vm_num: num=val.num(); break; diff --git a/test/calc.nas b/test/calc.nas index 77b6f27..35f1a0d 100644 --- a/test/calc.nas +++ b/test/calc.nas @@ -38,6 +38,7 @@ var testfile=[ "test/calc.nas ", "test/choice.nas ", "test/class.nas ", + "test/diff.nas ", "test/exception.nas ", "test/fib.nas ", "test/filesystem.nas ", diff --git a/test/scalar.nas b/test/scalar.nas index 1c16f5b..49f46a8 100644 --- a/test/scalar.nas +++ b/test/scalar.nas @@ -191,4 +191,10 @@ var a={ } }; println(isa(a.new(),a)); # 1 -println(isa(a.new2(),a));# 0 \ No newline at end of file +println(isa(a.new2(),a));# 0 + +var a=[10,-10,0,1,2,3,nil,"string","hello",[],[0,1,2,3],{},{a:0,b:1,c:2},func{}]; +println("type\tsize\tnum\tsrc"); +foreach(var i;a){ + println(typeof(i),'\t',size(i),'\t',num(i),'\t',i); +} \ No newline at end of file