Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,2 @@
String myStr = 'test;
System.assert(myStr == 'something else', 'Assertion Failed Message');

View file

@ -0,0 +1,2 @@
Integer i = 5;
System.assertEquals(6, i, 'Expected 6, received ' + i);

View file

@ -0,0 +1,2 @@
Integer i = 5;
System.assertNotEquals(5, i, 'Expected different value than ' + i);

View file

@ -0,0 +1 @@
A=42??Returnʳ

View file

@ -0,0 +1 @@
ASSERT(a = 42,'A is not 42!',FAIL);

View file

@ -0,0 +1,9 @@
(assert (integer? 42)) → #t ;; success returns true
;; error and return to top level if not true;
(assert (integer? 'quarante-deux))
⛔ error: assert : assertion failed : (#integer? 'quarante-deux)
;; assertion with message (optional)
(assert (integer? 'quarante-deux) "☝️ expression must evaluate to the integer 42")
💥 error: ☝️ expression must evaluate to the integer 42 : assertion failed : (#integer? 'quarante-deux)

View file

@ -0,0 +1,8 @@
' FB 1.05.0 Win64
' requires compilation with -g switch
Dim a As Integer = 5
Assert(a = 6)
'The rest of the code will not be executed
Print a
Sleep

View file

@ -0,0 +1,6 @@
local(a) = 8
fail_if(
#a != 42,
error_code_runtimeAssertion,
error_msg_runtimeAssertion + ": #a is not 42"
)

View file

@ -0,0 +1,17 @@
-- in a movie script
on assert (ok, message)
if not ok then
if not voidP(message) then _player.alert(message)
abort -- exits from current call stack, i.e. also from the caller function
end if
end
-- anywhere in the code
on test
x = 42
assert(x=42, "Assertion 'x=42' failed")
put "this shows up"
x = 23
assert(x=42, "Assertion 'x=42' failed")
put "this will never show up"
end

View file

@ -0,0 +1,2 @@
var a = 42
assert(a == 42)

View file

@ -0,0 +1,5 @@
: testInteger(n, m)
assert: [ n isInteger ]
assert: [ n 42 == ]
System.Out "Assertions are ok, parameters are : " << n << ", " << m << cr ;

View file

@ -0,0 +1,7 @@
type int42(object i)
return i=42
end type
int42 i
i = 41 -- type-check failure

View file

@ -0,0 +1,13 @@
global constant DEBUG = 0 -- (or any other identifier name can be used)
global procedure assert(integer flag, string msg)
if DEBUG then
if not flag then
{} = message_box(msg,"failed assertion",MB_OK) -- or
puts(1,msg) -- , and/or
crash(msg) -- crash/ex.err report -- or
trace(1) -- start debugging
end if
end if
end function
assert(i=42,"i is not 42!!")

View file

@ -0,0 +1,2 @@
if i!=42 then ?9/0 end if
if i!=42 then crash("i is not 42!!") end if

View file

@ -0,0 +1,3 @@
x = 42
assert( x = 42 )
assert( x = 100 )

View file

@ -0,0 +1,2 @@
var num = pick(0..100);
assert_eq(num, 42); # dies when "num" is not 42

View file

@ -0,0 +1,6 @@
var a = 5
//...input or change a here
assert(a == 42) // aborts program when a is not 42
assert(a == 42, "Error message") // aborts program
// when a is not 42 with "Error message" for the message
// the error message must be a static string