diff options
author | Andreas Rumpf <andreas@andi> | 2008-06-22 16:14:11 +0200 |
---|---|---|
committer | Andreas Rumpf <andreas@andi> | 2008-06-22 16:14:11 +0200 |
commit | 405b86068e6a3d39970b9129ceec0a9108464b28 (patch) | |
tree | c0449946f54baae6ea88baf453157ddd7faa8f86 /tests/tobjects.nim | |
download | Nim-405b86068e6a3d39970b9129ceec0a9108464b28.tar.gz |
Initial import
Diffstat (limited to 'tests/tobjects.nim')
-rwxr-xr-x | tests/tobjects.nim | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/tobjects.nim b/tests/tobjects.nim new file mode 100755 index 000000000..54e1bd3ac --- /dev/null +++ b/tests/tobjects.nim @@ -0,0 +1,48 @@ +import + io + +type + TBase = object + x, y: int + + TSubclass = object of TBase + c: int + case c + of 0, 1, 2, 3: + a, b: int + of 4: + d, e, f: char + n: bool + +var + global: int + +var + s: string + r: float = 0.0 + i: int = 500 + 400 + +case i +of 500..999: write(stdout, "ha!\n") +of 1000..3000, 12: write(stdout, "ganz schön groß\n") +of 1, 2, 3: write(stdout, "1 2 oder 3\n") +else: write(stdout, "sollte nicht passieren\n") + +case r +of 0.0, 0.125..0.4444: write(stdout, "kleiner als 0.5\n") +else: write(stdout, "weiß nicht\n") + +case readLine(stdin) +of "Rumpf": write(stdout, "Hallo Meister!\n") +of "Andreas": write(stdout, "Hallo Meister!\n") +else: write(stdout, "Nicht mein Meister!\n") + +global = global + 1 +write(stdout, "Hallo wie heißt du? \n") +s = readLine(stdin) +i = 0 +while i < length(s): + if s[i] == 'c': write(stdout, "'c' in deinem Namen gefunden\n") + i = i + 1 + +write(stdout, "Du heißt " & s) |