Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
2
Task/Assertions/Apex/assertions-1.apex
Normal file
2
Task/Assertions/Apex/assertions-1.apex
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
String myStr = 'test;
|
||||
System.assert(myStr == 'something else', 'Assertion Failed Message');
|
||||
2
Task/Assertions/Apex/assertions-2.apex
Normal file
2
Task/Assertions/Apex/assertions-2.apex
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Integer i = 5;
|
||||
System.assertEquals(6, i, 'Expected 6, received ' + i);
|
||||
2
Task/Assertions/Apex/assertions-3.apex
Normal file
2
Task/Assertions/Apex/assertions-3.apex
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Integer i = 5;
|
||||
System.assertNotEquals(5, i, 'Expected different value than ' + i);
|
||||
1
Task/Assertions/Axe/assertions.axe
Normal file
1
Task/Assertions/Axe/assertions.axe
Normal file
|
|
@ -0,0 +1 @@
|
|||
A=42??Returnʳ
|
||||
1
Task/Assertions/ECL/assertions.ecl
Normal file
1
Task/Assertions/ECL/assertions.ecl
Normal file
|
|
@ -0,0 +1 @@
|
|||
ASSERT(a = 42,'A is not 42!',FAIL);
|
||||
9
Task/Assertions/EchoLisp/assertions.echolisp
Normal file
9
Task/Assertions/EchoLisp/assertions.echolisp
Normal 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)
|
||||
8
Task/Assertions/FreeBASIC/assertions.freebasic
Normal file
8
Task/Assertions/FreeBASIC/assertions.freebasic
Normal 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
|
||||
6
Task/Assertions/Lasso/assertions.lasso
Normal file
6
Task/Assertions/Lasso/assertions.lasso
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
local(a) = 8
|
||||
fail_if(
|
||||
#a != 42,
|
||||
error_code_runtimeAssertion,
|
||||
error_msg_runtimeAssertion + ": #a is not 42"
|
||||
)
|
||||
17
Task/Assertions/Lingo/assertions.lingo
Normal file
17
Task/Assertions/Lingo/assertions.lingo
Normal 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
|
||||
2
Task/Assertions/Nim/assertions.nim
Normal file
2
Task/Assertions/Nim/assertions.nim
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
var a = 42
|
||||
assert(a == 42)
|
||||
5
Task/Assertions/Oforth/assertions.oforth
Normal file
5
Task/Assertions/Oforth/assertions.oforth
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
: testInteger(n, m)
|
||||
assert: [ n isInteger ]
|
||||
assert: [ n 42 == ]
|
||||
|
||||
System.Out "Assertions are ok, parameters are : " << n << ", " << m << cr ;
|
||||
7
Task/Assertions/Phix/assertions-1.phix
Normal file
7
Task/Assertions/Phix/assertions-1.phix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
type int42(object i)
|
||||
return i=42
|
||||
end type
|
||||
|
||||
int42 i
|
||||
|
||||
i = 41 -- type-check failure
|
||||
13
Task/Assertions/Phix/assertions-2.phix
Normal file
13
Task/Assertions/Phix/assertions-2.phix
Normal 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!!")
|
||||
2
Task/Assertions/Phix/assertions-3.phix
Normal file
2
Task/Assertions/Phix/assertions-3.phix
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
if i!=42 then ?9/0 end if
|
||||
if i!=42 then crash("i is not 42!!") end if
|
||||
3
Task/Assertions/Ring/assertions.ring
Normal file
3
Task/Assertions/Ring/assertions.ring
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
x = 42
|
||||
assert( x = 42 )
|
||||
assert( x = 100 )
|
||||
2
Task/Assertions/Sidef/assertions.sidef
Normal file
2
Task/Assertions/Sidef/assertions.sidef
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
var num = pick(0..100);
|
||||
assert_eq(num, 42); # dies when "num" is not 42
|
||||
6
Task/Assertions/Swift/assertions.swift
Normal file
6
Task/Assertions/Swift/assertions.swift
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue