A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
2
Task/Assertions/Factor/assertions.factor
Normal file
2
Task/Assertions/Factor/assertions.factor
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
USING: kernel ;
|
||||
42 assert=
|
||||
19
Task/Assertions/GAP/assertions.gap
Normal file
19
Task/Assertions/GAP/assertions.gap
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# See section 7.5 of reference manual
|
||||
|
||||
# GAP has assertions levels. An assertion is tested if its level
|
||||
# is less then the global level.
|
||||
|
||||
# Set global level
|
||||
SetAssertionLevel(10);
|
||||
|
||||
a := 1;
|
||||
Assert(20, a > 1, "a should be greater than one");
|
||||
# nothing happens
|
||||
|
||||
a := 1;
|
||||
Assert(4, a > 1, "a should be greater than one");
|
||||
# error
|
||||
|
||||
# Show current global level
|
||||
AssertionLevel();
|
||||
# 10
|
||||
3
Task/Assertions/Groovy/assertions-1.groovy
Normal file
3
Task/Assertions/Groovy/assertions-1.groovy
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
def checkTheAnswer = {
|
||||
assert it == 42 : "This: " + it + " is not the answer!"
|
||||
}
|
||||
4
Task/Assertions/Groovy/assertions-2.groovy
Normal file
4
Task/Assertions/Groovy/assertions-2.groovy
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
println "before 42..."
|
||||
checkTheAnswer(42)
|
||||
println "before 'Hello Universe'..."
|
||||
checkTheAnswer("Hello Universe")
|
||||
5
Task/Assertions/Icon/assertions-1.icon
Normal file
5
Task/Assertions/Icon/assertions-1.icon
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
...
|
||||
runerr(n,( expression ,"Assertion/error - message.")) # Throw (and possibly trap) an error number n if expression succeeds.
|
||||
...
|
||||
stop(( expression ,"Assertion/stop - message.")) # Terminate program if expression succeeds.
|
||||
...
|
||||
12
Task/Assertions/Icon/assertions-2.icon
Normal file
12
Task/Assertions/Icon/assertions-2.icon
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
$define DEBUG 1 # this allows the assertions to go through
|
||||
|
||||
procedure check (a)
|
||||
if DEBUG then stop (42 = a, " is invalid value for 'a'")
|
||||
write (a)
|
||||
end
|
||||
|
||||
procedure main ()
|
||||
check (10)
|
||||
check (42)
|
||||
check (12)
|
||||
end
|
||||
1
Task/Assertions/J/assertions.j
Normal file
1
Task/Assertions/J/assertions.j
Normal file
|
|
@ -0,0 +1 @@
|
|||
assert n = 42
|
||||
9
Task/Assertions/Julia/assertions.julia
Normal file
9
Task/Assertions/Julia/assertions.julia
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#assert() function takes expression as 1st argument, failed-assertion message as optional 2nd argument
|
||||
julia> assert(x==42,"x is not 42")
|
||||
ERROR: assertion failed: x is not 42
|
||||
#@assert macro checks the supplied conditional expression, with the expression returned in the failed-assertion message
|
||||
julia> @assert x==42
|
||||
ERROR: assertion failed: :((x==42))
|
||||
#Julia also has type assertions of the form, x::Type which can be appended to a variable for type-checking at any point
|
||||
julia> x::String
|
||||
ERROR: type: typeassert: expected String, got Int32
|
||||
1
Task/Assertions/Lisaac/assertions.lisaac
Normal file
1
Task/Assertions/Lisaac/assertions.lisaac
Normal file
|
|
@ -0,0 +1 @@
|
|||
? { n = 42 };
|
||||
3
Task/Assertions/Maple/assertions.maple
Normal file
3
Task/Assertions/Maple/assertions.maple
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
a := 5:
|
||||
ASSERT( a = 42 );
|
||||
ASSERT( a = 42, "a is not the answer to life, the universe, and everything" );
|
||||
1
Task/Assertions/Mathematica/assertions.mathematica
Normal file
1
Task/Assertions/Mathematica/assertions.mathematica
Normal file
|
|
@ -0,0 +1 @@
|
|||
Assert[var===42]
|
||||
1
Task/Assertions/Metafont/assertions-1.metafont
Normal file
1
Task/Assertions/Metafont/assertions-1.metafont
Normal file
|
|
@ -0,0 +1 @@
|
|||
def assert(expr t) = if not (t): errmessage("assertion failed") fi enddef;
|
||||
3
Task/Assertions/Metafont/assertions-2.metafont
Normal file
3
Task/Assertions/Metafont/assertions-2.metafont
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
n := 41;
|
||||
assert(n=42);
|
||||
message "ok";
|
||||
1
Task/Assertions/Modula-3/assertions.mod3
Normal file
1
Task/Assertions/Modula-3/assertions.mod3
Normal file
|
|
@ -0,0 +1 @@
|
|||
<*ASSERT a = 42*>
|
||||
Loading…
Add table
Add a link
Reference in a new issue