Closed WebFreak001 closed 9 years ago
Update: break in while seems to work just fine
function foo()
while(true) do
break
loop
return "hello"
end
duck.println(foo())
Maybe add same functionality to return?
Good catch.
happened when i was writing an array length function in duck
Maybe adding more unittests will prevent this?
Tests would be great. We have a framework for testing, but we don't have any unit tests currently.
I fixed this issue in the latest revision: https://github.com/gregtour/duck-lang/commit/6182733936279ec5f7e00709882ea6bce43a4beb
As a heads up, automated unit tests have been added between e637ca9 and ece6389.
See: https://github.com/gregtour/duck-lang/blob/master/test/testcases.txt
If you find any more bugs or issues please report them and once fixed we will provide the proper tests to prevent regression.
I think it would be also useful to have embedded unittests in duck code like this:
unittest
a = 5
b = 4
assert(a + b == 9, "Invalid integer addition")
end
They should be like functions that cant be called manually, but instead get called before everything else when running with a unittest flag or something like that.
That's fine, but it's possible they might not be tested if the interpreter fails.
In any case, it's possible to use an assert function to quit with an error and still set up tests in this way.
this code should actually just output
hello
:Because return breaks out of while loops but in here it doesn't. It should return "hello" right at the first iteration but its being stuck there.