September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,21 @@
BEGIN {
meaning = 6 * 7
assert(meaning == 42, "Integer mathematics failed")
assert(meaning == 42)
meaning = strtonum("42 also known as forty-two")
assert(meaning == 42, "Built-in function failed")
meaning = "42"
assert(meaning == 42, "Dynamic type conversion failed")
meaning = 6 * 9
assert(meaning == 42, "Ford Prefect's experiment failed")
print "That's all folks"
exit
}
# Errormsg is optional, displayed if assertion fails
function assert(cond, errormsg){
if (!cond) {
if (errormsg != "") print errormsg
exit 1
}
}

View file

@ -0,0 +1,24 @@
' Assertions
answer = assertion(42)
PRINT "The ultimate answer is indeed ", answer
PRINT "Now, expect a failure, unless NDEBUG defined at compile time"
answer = assertion(41)
PRINT answer
END
' Ensure the given number is the ultimate answer
FUNCTION assertion(NUMBER i)
' BaCon can easily be intimately integrated with C
USEH
#include <assert.h>
END USEH
' If the given expression is not true, abort the program
USEC
assert(i == 42);
END USEC
RETURN i
END FUNCTION

View file

@ -1,8 +1,16 @@
public static void main(String[] args){
int a;
//...input or change a here
assert a == 42;//throws an AssertionError when a is not 42
assert a == 42 : "Error message"; //throws an AssertionError
//when a is not 42 with "Error message" for the message
//the error message can be any non-void expression
public class Assertions {
public static void main(String[] args) {
int a = 13;
// ... some real code here ...
assert a == 42;
// Throws an AssertionError when a is not 42.
assert a == 42 : "Error message";
// Throws an AssertionError when a is not 42,
// with "Error message" for the message.
// The error message can be any non-void expression.
}
}

View file

@ -0,0 +1,6 @@
// version 1.0.6 (assert.kt)
fun main(args: Array<String>) {
val a = 42
assert(a == 43)
}

View file

@ -1,2 +1,2 @@
var a = 42
assert(a == 42)
assert(a == 42, "Not 42!")

View file

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

View file

@ -0,0 +1 @@
assert( n = 42 );

View file

@ -0,0 +1 @@
assert x<y if z>0

View file

@ -0,0 +1 @@
confirm file titanium.dta

View file

@ -0,0 +1,2 @@
if (`n'==42) error 3
* Will print "no dataset in use"

View file

@ -0,0 +1,4 @@
if (`n'==42) {
display as error "The correct answer is not 42."
exit 54
}

View file

@ -0,0 +1,2 @@
n:=42; (n==42) or throw(Exception.AssertionError);
n=41; (n==42) or throw(Exception.AssertionError("I wanted 42!"));