forked from ground/ground
More stuff
This commit is contained in:
89
tests/everything.grnd
Normal file
89
tests/everything.grnd
Normal file
@@ -0,0 +1,89 @@
|
||||
# I/O
|
||||
|
||||
stdlnout "Hello there!"
|
||||
stdout "What is your name? "
|
||||
stdin &name
|
||||
add "Hello, " $name &out
|
||||
stdlnout $out
|
||||
|
||||
# Types
|
||||
stdlnout "dingus"
|
||||
stdlnout 7
|
||||
stdlnout 3.14159
|
||||
stdlnout true
|
||||
stdlnout 'e'
|
||||
|
||||
# Variables
|
||||
|
||||
set &testVar "This is a test"
|
||||
stdlnout $testVar
|
||||
|
||||
# Lists
|
||||
|
||||
setlist *testList "Item 1" "Another Item" "Item the Third"
|
||||
getlistat *testList 2 &tmp
|
||||
stdlnout $tmp
|
||||
|
||||
setlistat *testList 1 "I changed this item"
|
||||
getlistat *testList 1 &tmp
|
||||
stdlnout $tmp
|
||||
|
||||
listappend *testList "I appended this item"
|
||||
getlistat *testList 3 &tmp
|
||||
stdlnout $tmp
|
||||
|
||||
getlistsize *testList &tmp
|
||||
stdlnout $tmp
|
||||
|
||||
# String Operations
|
||||
|
||||
set &testStr "dingus"
|
||||
|
||||
getstrsize $testStr &tmp
|
||||
stdlnout $tmp
|
||||
|
||||
getstrcharat $testStr 3 &tmp
|
||||
stdlnout $tmp
|
||||
|
||||
# Maths
|
||||
|
||||
add 1 1 &tmp
|
||||
stdlnout $tmp
|
||||
|
||||
subtract 10 5 &tmp
|
||||
stdlnout $tmp
|
||||
|
||||
multiply 15 15 &tmp
|
||||
stdlnout $tmp
|
||||
|
||||
divide 36 4 &tmp
|
||||
stdlnout $tmp
|
||||
|
||||
# Comparisons
|
||||
|
||||
equal 5 5 &tmp
|
||||
stdlnout $tmp
|
||||
|
||||
inequal 5 5 &tmp
|
||||
stdlnout $tmp
|
||||
|
||||
greater 10 5 &tmp
|
||||
stdlnout $tmp
|
||||
|
||||
lesser 10 5 &tmp
|
||||
stdlnout $tmp
|
||||
|
||||
# Control flow
|
||||
|
||||
set &counter 0
|
||||
|
||||
@myLabel
|
||||
add $counter 1 &counter
|
||||
stdlnout $counter
|
||||
inequal $counter 10 &case
|
||||
if $case %myLabel
|
||||
|
||||
# That's it!
|
||||
|
||||
stdlnout "Everything ran! Check the output to see if it is what is expected."
|
||||
end 0
|
Reference in New Issue
Block a user