langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
2
Task/Assertions/Nimrod/assertions.nimrod
Normal file
2
Task/Assertions/Nimrod/assertions.nimrod
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
var a = 42
|
||||
assert(a == 42)
|
||||
3
Task/Assertions/OCaml/assertions.ocaml
Normal file
3
Task/Assertions/OCaml/assertions.ocaml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
let a = get_some_value () in
|
||||
assert (a = 42); (* throws Assert_failure when a is not 42 *)
|
||||
(* evaluate stuff to return here when a is 42 *)
|
||||
7
Task/Assertions/Oberon-2/assertions.oberon-2
Normal file
7
Task/Assertions/Oberon-2/assertions.oberon-2
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
MODULE Assertions;
|
||||
VAR
|
||||
a: INTEGER;
|
||||
BEGIN
|
||||
a := 40;
|
||||
ASSERT(a = 42);
|
||||
END Assertions.
|
||||
1
Task/Assertions/Objective-C/assertions-1.m
Normal file
1
Task/Assertions/Objective-C/assertions-1.m
Normal file
|
|
@ -0,0 +1 @@
|
|||
NSAssert(a == 42, @"Error message");
|
||||
1
Task/Assertions/Objective-C/assertions-2.m
Normal file
1
Task/Assertions/Objective-C/assertions-2.m
Normal file
|
|
@ -0,0 +1 @@
|
|||
NSAssert1(a == 42, @"a is not 42, a is actually %d", a); # has 1 formatting arg, so use NSAssert"1"
|
||||
8
Task/Assertions/Oz/assertions.oz
Normal file
8
Task/Assertions/Oz/assertions.oz
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
declare
|
||||
proc {PrintNumber N}
|
||||
N=42 %% assert
|
||||
{Show N}
|
||||
end
|
||||
in
|
||||
{PrintNumber 42} %% ok
|
||||
{PrintNumber 11} %% throws
|
||||
10
Task/Assertions/PARI-GP/assertions.pari
Normal file
10
Task/Assertions/PARI-GP/assertions.pari
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#include <assert.h>
|
||||
|
||||
void
|
||||
test()
|
||||
{
|
||||
int a;
|
||||
// ... input or change a here
|
||||
|
||||
assert(a == 42); // Aborts program if a is not 42, unless the NDEBUG macro was defined
|
||||
}
|
||||
18
Task/Assertions/PL-I/assertions.pli
Normal file
18
Task/Assertions/PL-I/assertions.pli
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/* PL/I does not have an assert function as such, */
|
||||
/* but it is something that can be implemented in */
|
||||
/* any of several ways. A straight-forward way */
|
||||
/* raises a user-defined interrupt. */
|
||||
|
||||
on condition (assert_failure) snap
|
||||
put skip list ('Assert failure');
|
||||
....
|
||||
if a ^= b then signal condition(assert_failure);
|
||||
|
||||
/* Another way is to use the preprocessor, thus: */
|
||||
%assert: procedure (a, b) returns (character);
|
||||
return ('if ' || a || '^=' || b ||
|
||||
' then signal condition(assert_failure);');
|
||||
%end assert;
|
||||
%activate assert;
|
||||
|
||||
assert(a, 42);
|
||||
8
Task/Assertions/Perl-6/assertions.pl6
Normal file
8
Task/Assertions/Perl-6/assertions.pl6
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
my $a = (1..100).pick;
|
||||
|
||||
# with a (non-hygienic) macro
|
||||
macro assert ($x) { "$x or die 'assertion failed: $x'" }
|
||||
assert('$a == 42');
|
||||
|
||||
# but usually we just say
|
||||
$a == 42 or die "$x ain't 42";
|
||||
8
Task/Assertions/PureBasic/assertions-1.purebasic
Normal file
8
Task/Assertions/PureBasic/assertions-1.purebasic
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
Macro Assert(TEST,MSG="Assert: ")
|
||||
CompilerIf #PB_Compiler_Debugger
|
||||
If Not (TEST)
|
||||
Debug MSG+" Line="+Str(#PB_Compiler_Line)+" in "+#PB_Compiler_File
|
||||
CallDebugger
|
||||
EndIf
|
||||
CompilerEndIf
|
||||
EndMacro
|
||||
4
Task/Assertions/PureBasic/assertions-2.purebasic
Normal file
4
Task/Assertions/PureBasic/assertions-2.purebasic
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
A=42
|
||||
Assert(A=42,"Assert that A=42")
|
||||
A=42-1
|
||||
Assert(A=42)
|
||||
6
Task/Assertions/RLaB/assertions.rlab
Normal file
6
Task/Assertions/RLaB/assertions.rlab
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// test if 'a' is 42, and if not stop the execution of the code and print
|
||||
// some error message
|
||||
if (a != 42)
|
||||
{
|
||||
stop("a is not 42 as expected, therefore I stop until this issue is resolved!");
|
||||
}
|
||||
1
Task/Assertions/SPARK/assertions-1.spark
Normal file
1
Task/Assertions/SPARK/assertions-1.spark
Normal file
|
|
@ -0,0 +1 @@
|
|||
-# check X = 42;
|
||||
1
Task/Assertions/SPARK/assertions-2.spark
Normal file
1
Task/Assertions/SPARK/assertions-2.spark
Normal file
|
|
@ -0,0 +1 @@
|
|||
-# assert X = 42;
|
||||
3
Task/Assertions/SPARK/assertions-3.spark
Normal file
3
Task/Assertions/SPARK/assertions-3.spark
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
procedure P (X : in out Integer);
|
||||
--# derives X from *;
|
||||
--# pre X = 42;
|
||||
3
Task/Assertions/SPARK/assertions-4.spark
Normal file
3
Task/Assertions/SPARK/assertions-4.spark
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
procedure P (X : in out Integer);
|
||||
--# derives X from *;
|
||||
--# post X = 42;
|
||||
2
Task/Assertions/SPARK/assertions-5.spark
Normal file
2
Task/Assertions/SPARK/assertions-5.spark
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
X := 7;
|
||||
--# check X = 42;
|
||||
3
Task/Assertions/Slate/assertions.slate
Normal file
3
Task/Assertions/Slate/assertions.slate
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
load: 'src/lib/assert.slate'.
|
||||
define: #n -> 7.
|
||||
assert: n = 42 &description: 'That is not the Answer.'.
|
||||
5
Task/Assertions/VBScript/assertions-1.vbscript
Normal file
5
Task/Assertions/VBScript/assertions-1.vbscript
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
sub Assert( boolExpr, strOnFail )
|
||||
if not boolExpr then
|
||||
Err.Raise vbObjectError + 99999, , strOnFail
|
||||
end if
|
||||
end sub
|
||||
3
Task/Assertions/VBScript/assertions-2.vbscript
Normal file
3
Task/Assertions/VBScript/assertions-2.vbscript
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
dim i
|
||||
i = 43
|
||||
Assert i=42, "There's got to be more to life than this!"
|
||||
2
Task/Assertions/VBScript/assertions-3.vbscript
Normal file
2
Task/Assertions/VBScript/assertions-3.vbscript
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
>cscript "C:\foo\assert.vbs"
|
||||
C:\foo\assert.vbs(3, 3) (null): There's got to be more to life than this!
|
||||
4
Task/Assertions/Vala/assertions.vala
Normal file
4
Task/Assertions/Vala/assertions.vala
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
int a = 42;
|
||||
int b = 33;
|
||||
assert (a == 42);
|
||||
assert (b == 42); // will break the program with "assertion failed" error
|
||||
1
Task/Assertions/Visual-Basic/assertions.vb
Normal file
1
Task/Assertions/Visual-Basic/assertions.vb
Normal file
|
|
@ -0,0 +1 @@
|
|||
Debug.Assert i = 42
|
||||
10
Task/Assertions/XPL0/assertions.xpl0
Normal file
10
Task/Assertions/XPL0/assertions.xpl0
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
proc Fatal(Str); \Display error message and terminate program
|
||||
char Str;
|
||||
[\return; uncomment this if "assertions" are to be disabled
|
||||
SetVid(3); \set normal text display if program uses graphics
|
||||
Text(0, Str); \display error message
|
||||
ChOut(0, 7); \sound the bell
|
||||
exit 1; \terminate the program; pass optional error code to DOS
|
||||
];
|
||||
|
||||
if X#42 then Fatal("X#42");
|
||||
Loading…
Add table
Add a link
Reference in a new issue