DEADSOFTWARE

Добавлена конструкция IF-THEN-ELSE-END
[dsw-obn.git] / src / test.c
index cacf00d30d71189e19360a4b2467ba052f037858..a144f3616074e1f8891dbc30af0007420bad0ef9 100644 (file)
@@ -4,52 +4,41 @@
 
 #include "../include/oberon.h"
 
-/*
 static char source_test[] =
        "(* Main module *)"
        "MODULE Test;"
        "IMPORT Out;"
-       "VAR"
-       "  msg : ARRAY 20 OF CHAR;"
-       "BEGIN"
-       "  msg := ''"
-       "END Test."
-;
-*/
-
-static char source_test[] =
-       "(* Main module *)"
-       "MODULE Test;"
-       "IMPORT Out;"
-       "CONST"
-       "  helloworld = 'Hello World!';"
-       "  null = 0X;"
-       "  space = 020X;"
-       "  bang = 021X;"
-       "  h = 048X;"
-       "  e = 045X;"
-       "  l = 04CX;"
-       "  o = 04FX;"
-       "  w = 057X;"
-       "  r = 052X;"
-       "  d = 044X;"
        ""
        "TYPE"
-       "  Ident = ARRAY 20 OF CHAR;"
-       "  PrintString = PROCEDURE (str : ARRAY OF CHAR);"
+       "  R = INTEGER;"
        ""
-       "VAR"
-       "  msg   : Ident;"
-       "  print : PrintString;"
+       "PROCEDURE Factorial(n : R) : R;"
+       "BEGIN"
+       "  IF n <= 1 THEN"
+       "    RETURN 1;"
+       "  ELSE"
+       "    RETURN n * Factorial(n - 1);"
+       "  END;"
+       "  RETURN 0; (* Детектор ретурнов - дерьмо *)"
+       "END Factorial;"
        ""
        "BEGIN"
-       "  msg := helloworld;"
-       "  print := Out.String;"
-       "  Out.Open;"
-       "  print(msg);"
-       "  Out.Ln;"
-       "  print(\"It's works!\");"
-       "  Out.Ln;"
+       "  Out.Open();"
+       "  Out.Int(Factorial(0), 0); Out.Ln;"
+       "  Out.Int(Factorial(1), 0); Out.Ln;"
+       "  Out.Int(Factorial(2), 0); Out.Ln;"
+       "  Out.Int(Factorial(3), 0); Out.Ln;"
+       "  Out.Int(Factorial(4), 0); Out.Ln;"
+       "  Out.Int(Factorial(5), 0); Out.Ln;"
+       "  Out.Int(Factorial(6), 0); Out.Ln;"
+       "  Out.Int(Factorial(7), 0); Out.Ln;"
+       "  Out.Int(Factorial(8), 0); Out.Ln;"
+       "  Out.Int(Factorial(9), 0); Out.Ln;"
+       "  Out.Int(Factorial(10), 0); Out.Ln;"
+       "  Out.Int(Factorial(11), 0); Out.Ln;"
+       "  Out.Int(Factorial(12), 0); Out.Ln;"
+       "  Out.Int(Factorial(13), 0); Out.Ln;"
+       "  Out.Int(Factorial(14), 0); Out.Ln;"
        "END Test."
 ;