Create a tiny Test Framework. #27
MaxTymchii
started this conversation in
Show and tell
Replies: 4 comments 2 replies
-
Tiny update.
I tried like this but it also didn't work for me...
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Great thx for adding unit tests and finding problems this is exactly what I
want help with. I will add this to the regression testing after making sure
they all pass
…On Sun, Jun 9, 2024 at 3:04 PM Max ***@***.***> wrote:
Tiny update.
println("Array value: ");
var arrayValue[] = {1, 2, 3, 4};
println(arrayValue.isRawArray());
println(arrayValue.isWrenchArray());
println("Hash value: ");
var hashValue = {"a" : 1, "b" : 2, "c" : 3};
println(hashValue.isHash());
println(hashValue.asHash());
println(hashValue.isHashTable());
I tried like this but it also didn't work for me...
Array value:
0
0
Hash value:
0
0
0
—
Reply to this email directly, view it on GitHub
<#27 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALIKAZJOPDEJ3GVCUQV7EDZGSRKBAVCNFSM6AAAAABJBDO42WVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TOMRQGYZDI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
-
wow, you're killing me :)
Okay so there is a lot of hash/array functionality I never added because no
one needed it, in particular comparing them as a whole. So I fixed that and
added all that functionality in. I also set the stage for the next thing
coming.
This doesn't work:
var intValue = 1;
println("Int value: ");
println(a.isInt());
println(a.asInt());
because .asInt() and all the rest are not in wrench space, it's only in c++
space, so the compiler treats it as a null-hashed value and returns zero
since it wasn't set.
However I imagine a world where this would work:
var a = 10;
a.isInt(); // syntactic sugar for TypeOf<a>::isInt( a )
a.isInt(1,2); // syntactic sugar for TypeOf<a>::doSomething( a, 1, 2 )
And then you could define the TypeOf<a> functions.. most obviously like
this:
function TypeOf<a>::isInt( a )
{
// definition
}
or of course:
struct A
{
function memberFunc( a )
{
}
}
That way I could include a library that would define them all, iff the
developer didn't mind the extra space they would occupy in ROM.
I am still chewing this over, and in any case will require a major overhaul
to the compiler, though very little change (if any!) to the VM.
5.0.2 has your code in as tests/unit_test1.c which must pass for release
(note I also use/test the import function in it) and has all the issues
with it fixed.
The other code you sent with the _size problem is something I am working on
now, hash tables never knew their size, "10" is just twice "5" which is the
mod for the table :P I am brainstorming how to properly fix it up and will
most likely have a solution shortly.
…-Curt
On Sun, Jun 9, 2024 at 3:44 PM Max ***@***.***> wrote:
Ok, I will wait for updates.
—
Reply to this email directly, view it on GitHub
<#27 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALIKAZE4AG3LOHLETNOZXTZGSWC5AVCNFSM6AAAAABJBDO42WVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TOMRQHAZTO>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
-
the concatenation is a rough one, it has to do with an optimization I made
in the addition parser.. since addition can be in any order.. but strings..
well it MATTERS.. it's going to be a rough fix.
Struct equality? You're killin' me, smalls.
No problem I'll add that.
…-Curt
On Mon, Jun 10, 2024 at 5:21 PM Max ***@***.***> wrote:
Big-big thanks! All my tests also passed. awesome fix!
P.S: I have a bonus for you)))))) equality of structs.
struct S {
var a;
var b;
var c;
};
struct V {
var a;
var b;
var c;
};
var s1 = S(1, 2, 3);
var s2 = S(1, 2, 3);
assertEqual(s1, s2, "S(1, 2, 3) and S(1, 2, 3) Structs are equal");
var s3 = S(1, 2, 3);
var s4 = S(1, 2, 4);
assertNotEqual(s3, s4, "S(1, 2, 3) and S(1, 2, 4) Structs are equal");
var v1 = V(1, 2, 3);
assertNotEqual(s1, v1, "S(1, 2, 3) and V(1, 2, 3) Structs are equal");
var y1 = {"a" : 1, "b" : 2, "c" : 3};
var array = {1, 2, 3};
assertNotEqual(v1, y, "V(1, 2, 3) and {a: 1, b: 2, c: {d, e}} Struct and HashTable are equal");
assertNotEqual(y1, v1, "{a: 1, b: 2, c: 3} and V(1, 2, 3) HashTable and Struct are equal");
assertNotEqual(array, v1, "{1, 2, 3} and V(1, 2, 3) Array and Struct are equal");
Results:
PASS
FAIL: S(1, 2, 3) and S(1, 2, 4) Structs are equal
FAIL: S(1, 2, 3) and V(1, 2, 3) Structs are equal
PASS
PASS
PASS
—
Reply to this email directly, view it on GitHub
<#27 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALIKAZ2GDU7HZQZZ3NPXF3ZGYKHNAVCNFSM6AAAAABJBDO42WVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TOMZRHA2TA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
After the introduction of the import feature, creating new features became easier. I want to help from my side to make the code on the wrench more testable and stable. To do that, I started implementing a set of functions that can help from my point of view.
Here is what I have at this moment.
A set of tests:
Results:
As you can see there are some problems at a "Wrench Kingdom".
One of the solutions that I can propose is to compare types. For example check is it an array or hash for example:
Here is what I try to test:
My results:
As you can see I can't detect anything... Maybe you can propose some other way...
Regards,
Max.
Beta Was this translation helpful? Give feedback.
All reactions