V Forum

[ log in ]

Testing, access to structs

kcorey 2019-06-25 18:16

Just thinking about playing with the language a bit.

Writing one-file scripts is cute, but it's not reasonable to build larger, interesting apps.

So, I figured I'd do TDD using V.

Let's pick the bowling kata from Uncle Bob. Good enough place to start.

I create a file 'bowling.v' as well as 'bowling_test.v'. v run bowling_test.v runs.

In bowling_test.v, I want to create a test that forces me to write a Game struct:
fn test_game() {
game := Game{


This fails with "undefined: 'Game'". I get it, there's no way for the compiler to understand 'struct Game{}' in bowling.v.

I thought about making 'bowling' a module.

So, in bowling_test.v:
import bowling

The error that gets is: V panic: /Users/<username>//code/v//bowling doesn't exist

Ah, okay, so
import examples/bowling

pass=1 fn=``
panic: hello_world.v:5
unexpected token `println`

Seems that it's going through the 'example' directory.

Okay, move 'bowling' up to 'v'.

Now, 'v run bowling_test.v' gets stuck in a loop (I suspect because bowling_test.v is inside the bowling module).

So I'm perplexed. How does one use the 'v test filename' command to do TDD with V after all?

I want to import one file into another. I want to be able to call the functions in the source file.

Thoughts? (RTFM would be great if you tell me where, code would be better).

medvednikov 2019-06-25 21:39
Yes, this is broken right now.
medvednikov 2019-06-25 21:39
Thanks for reporting, will be fixed asap.
medvednikov 2019-06-25 21:39
Its a relatively simple fix. Ive added it to the 0.2 roadmap
medvednikov 2019-06-25 21:39
medvednikov 2019-06-25 21:39
And I need to fix the forum, I couldn't post this as one message :)
kcorey 2019-06-25 22:00
No worries, keep up the good work!

Powered by Vorum, open-source blogging/forum software written in V