[SCM] Lisaac compiler branch, master+stable, updated. lisaac-0.12-606-gf445725

Mildred Ki'Lya silkensedai at online.fr
Mon Mar 1 00:35:25 UTC 2010


The following commit has been merged in the master+stable branch:
commit c2d6262a2ccbc2199d34623b193f9622a37e7b16
Author: Mildred Ki'Lya <silkensedai at online.fr>
Date:   Sat Oct 10 01:16:40 2009 +0200

    Updated tests. LIP files are now used to describe tests.

diff --git a/run-tests.sh b/run-tests.sh
index 779004f..6bdccb7 100755
--- a/run-tests.sh
+++ b/run-tests.sh
@@ -70,6 +70,21 @@ header(){
   fi
 }
 
+test-patterns(){
+  while read pattern; do
+    [ -z "$pattern" ] && continue
+    if ! egrep -- "$pattern" <<<"$2" >/dev/null; then
+      echo " - Expected:    $pattern"
+      echo
+      echo "$2"
+      return 1
+    else
+      echo " - Match:       $pattern"
+    fi
+  done <<<"$1"
+  return 0
+}
+
 if $op_runcwd; then
   res=1
   echo
@@ -77,6 +92,53 @@ if $op_runcwd; then
   if [ -f test.sh -a -x test.sh ]; then
     ./test.sh
     res=$?
+  elif [ -f make.lip ]; then
+    lisaac -test-description 2>&1
+    args=(-test)
+    if ! lisaac -test-run 2>&1; then
+      args=("${args[@]}" -partial)
+      partial=true
+    else
+      partial=false
+    fi
+    compile="$(lisaac "${args[@]}" -o result.exe 2>&1)"
+    res=$?
+    echo
+    if [ $res != 0 ]; then
+      echo " - Compilation: $res"
+    else
+      echo " - Compilation: ok"
+    fi
+    if ! lisaac -test-compile; then
+      res=0
+    fi
+    if [ $res != 0 ]; then
+      echo
+      echo "$compile"
+    else
+      compile_patterns="$(lisaac -test-compile-patterns 2>&1)"
+      test-patterns "$compile_patterns" "$compile"
+      res=$?
+      if ! $partial && [ $res = 0 ]; then
+        run="$(./result.exe)"
+        res=$?
+        if [ $res != 0 ]; then
+          echo " - Execution:   $res"
+        else
+          echo " - Execution:   ok"
+        fi
+        run_patterns="$(lisaac -test-run-patterns 2>&1)"
+        test-patterns "$run_patterns" "$run"
+        res2=$?
+        if [ $res = 0 ]; then
+          res=$res2
+        fi
+        if [ $res2 = 0 ]; then
+          echo
+          echo "$run"
+        fi
+      fi
+    fi
   else
     echo "Unknown test: $op_testname"
   fi
diff --git a/tests/ambiguous_protoname/make.lip b/tests/ambiguous_protoname/make.lip
index d7c9289..0918259 100644
--- a/tests/ambiguous_protoname/make.lip
+++ b/tests/ambiguous_protoname/make.lip
@@ -1,7 +1,30 @@
+///////////////////////////////////////////////////////////////////////////////
+//                            Lisaac Installer                               //
+//                                                                           //
+//                   LSIIT - ULP - CNRS - INRIA - FRANCE                     //
+//                                                                           //
+//   This program is free software: you can redistribute it and/or modify    //
+//   it under the terms of the GNU General Public License as published by    //
+//   the Free Software Foundation, either version 3 of the License, or       //
+//   (at your option) any later version.                                     //
+//                                                                           //
+//   This program is distributed in the hope that it will be useful,         //
+//   but WITHOUT ANY WARRANTY; without even the implied warranty of          //
+//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           //
+//   GNU General Public License for more details.                            //
+//                                                                           //
+//   You should have received a copy of the GNU General Public License       //
+//   along with this program.  If not, see <http://www.gnu.org/licenses/>.   //
+//                                                                           //
+//                     http://isaacproject.u-strasbg.fr/                     //
+///////////////////////////////////////////////////////////////////////////////
+
 Section Inherit
 
   + parent :STRING;
 
+  + parent_test :STRING := "../test.lip";
+
 Section Private
 
   - front_end <-
@@ -10,3 +33,14 @@ Section Private
     path "./*";
     input_file := "main";
   );
+
+  + m_test_description :STRING :=
+    "Test if the error message contains non ambiguous prototype names\n\
+    \Test also if the compiler choose the nearer prototype in case of\n\
+    \conflicting prototype names\n";
+
+  + m_test_compile :BOOLEAN := FALSE;
+  + m_test_run :BOOLEAN := FALSE;
+
+  + m_test_compile_pattern :STRING :=
+    "Slot `toto' not found in `AMBIGUOUS_PROTONAME\\.PROTO'\\.";
diff --git a/tests/ambiguous_protoname/test.sh b/tests/ambiguous_protoname/test.sh
deleted file mode 100755
index ada6bec..0000000
--- a/tests/ambiguous_protoname/test.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#! /bin/sh
-
-
-echo "Test if the error message contains non ambiguous prototype names"
-
-expected="Slot \`toto' not found in \`AMBIGUOUS_PROTONAME.PROTO'."
-
-out="$(lisaac -partial 2>&1)"
-grep -q "$expected" <<<"$out" || \
-{
-  echo
-  echo "Expected: "
-  echo "$expected"
-  echo
-  echo "$out"
-  exit 1
-}
-
-exit $?
diff --git a/lib/standard/io/io.li b/tests/boolean_test3/make.lip
similarity index 80%
copy from lib/standard/io/io.li
copy to tests/boolean_test3/make.lip
index 181235d..3799ca4 100644
--- a/lib/standard/io/io.li
+++ b/tests/boolean_test3/make.lip
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-//                             Lisaac Library                                //
+//                            Lisaac Installer                               //
 //                                                                           //
 //                   LSIIT - ULP - CNRS - INRIA - FRANCE                     //
 //                                                                           //
@@ -18,17 +18,23 @@
 //                                                                           //
 //                     http://isaacproject.u-strasbg.fr/                     //
 ///////////////////////////////////////////////////////////////////////////////
-Section Header
-  
-  + name    := IO;
 
+Section Inherit
 
-  - copyright   := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
+  + parent :STRING;
 
-  - comment := "Standard Input Output.";
+  + parent_test :STRING := "../test.lip";
 
-Section Inherit
-  
-  - inherit_std_input:STD_INPUT := STD_INPUT;
-  
-  - inherit_std_output:STD_OUTPUT := STD_OUTPUT;
+Section Private
+
+  - front_end <-
+  (
+    general_front_end;
+    path "./*";
+    input_file := "boolean_test3";
+  );
+
+  + m_test_description :STRING :=
+    "Test that ( + b:BOOLEAN; b == TRUE) compiles\n";
+
+  + m_test_run :BOOLEAN := FALSE;
diff --git a/tests/boolean_test3/test.sh b/tests/boolean_test3/test.sh
deleted file mode 100755
index 5ca40af..0000000
--- a/tests/boolean_test3/test.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#! /bin/sh
-
-
-echo "Test ( + b:BOOLEAN; b == TRUE) compiles"
-
-compile="$(lisaac boolean_test3 -partial 2>&1)" || {
-  echo
-  echo "$compile"
-  exit 1
-}
-
-exit 0
diff --git a/tests/strict_type_parameter/dynamic_type.li b/tests/strict_type_parameter/dynamic_type.li
index a92b2d6..d9cf5ea 100644
--- a/tests/strict_type_parameter/dynamic_type.li
+++ b/tests/strict_type_parameter/dynamic_type.li
@@ -25,6 +25,10 @@ Section Header
   - copyright := "2009 Mildred Ki'Lya <http://ki.lya.online.fr>";
   - comment   := "Test dynamic type";
 
+Section Inherit
+
+  + parent:Expanded OBJECT;
+
 Section Public
 
   - get_dynamic_type e:Strict E :E <- E;
@@ -32,6 +36,9 @@ Section Public
   - main <-
   ( + s:ABSTRACT_STRING;
     + t:ABSTRACT_STRING;
+    + c:INTEGER;
+
+    c := exit_failure_code;
 
     s := "test";
     t := get_dynamic_type s;
@@ -43,7 +50,10 @@ Section Public
       "STRING".println;
     }.elseif {t = STRING_CONSTANT} then {
       "STRING_CONSTANT".println;
+      c := exit_success_code;
     } else {
       "???".println;
     };
+
+    die_with_code c;
   );
diff --git a/lib/standard/property/hashable.li b/tests/strict_type_parameter/make.lip
similarity index 79%
copy from lib/standard/property/hashable.li
copy to tests/strict_type_parameter/make.lip
index 7e136e6..1861ddb 100644
--- a/lib/standard/property/hashable.li
+++ b/tests/strict_type_parameter/make.lip
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-//                             Lisaac Library                                //
+//                            Lisaac Installer                               //
 //                                                                           //
 //                   LSIIT - ULP - CNRS - INRIA - FRANCE                     //
 //                                                                           //
@@ -18,26 +18,24 @@
 //                                                                           //
 //                     http://isaacproject.u-strasbg.fr/                     //
 ///////////////////////////////////////////////////////////////////////////////
-Section Header
-  
-  + name        := HASHABLE;
 
-
-  - copyright   := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-  
-  - comment     :=" .";
-    
 Section Inherit
-  
-  - parent_object:OBJECT := OBJECT;
-  
-Section Public
-  
-  - hash_code:INTEGER <-
-  // The hash-code value of `Current'.
+
+  + parent :STRING;
+
+  + parent_test :STRING := "../test.lip";
+
+Section Private
+
+  - front_end <-
   (
-    deferred;
-    // ? {  result >= 0 };
+    general_front_end;
+    path "./*";
+    input_file := "dynamic_type";
   );
 
+  + m_test_description :STRING :=
+    "Test if a Strict parameter type gives you the dynamic type\n";
 
+  + m_test_run_pattern :STRING :=
+    "dynamic_type = STRING_CONSTANT";
diff --git a/tests/strict_type_parameter/test.sh b/tests/strict_type_parameter/test.sh
deleted file mode 100755
index fbb27e8..0000000
--- a/tests/strict_type_parameter/test.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#! /bin/sh
-
-
-echo "Test if a Strict parameter type gives you the dynamic type"
-
-expected="dynamic_type = STRING_CONSTANT"
-
-compile="$(lisaac dynamic_type -q -o out.exe 2>&1)" || {
-  echo
-  echo "$compile"
-  exit 1
-}
-
-out="$(./out.exe)"
-grep -q "$expected" <<<"$out" || \
-{
-  echo
-  echo "Expected: $expected"
-  echo "Got:      $out"
-  exit 1
-}
-
-exit $?
diff --git a/lib/internal/portable/io/std_input_output.li b/tests/test.lip
similarity index 58%
copy from lib/internal/portable/io/std_input_output.li
copy to tests/test.lip
index aebb4a3..a0dc670 100644
--- a/lib/internal/portable/io/std_input_output.li
+++ b/tests/test.lip
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-//                             Lisaac Library                                //
+//                            Lisaac Installer                               //
 //                                                                           //
 //                   LSIIT - ULP - CNRS - INRIA - FRANCE                     //
 //                                                                           //
@@ -18,61 +18,71 @@
 //                                                                           //
 //                     http://isaacproject.u-strasbg.fr/                     //
 ///////////////////////////////////////////////////////////////////////////////
-Section Header
-  
-  + name        :=STD_INPUT_OUTPUT;
 
+Section Private
 
-  - copyright   := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
-  
-  - comment     :="To have the useful `io'";
-  
-Section Inherit
-  
-  - inherit_input_stream:INPUT_STREAM := INPUT_STREAM;
-
-  - inherit_output_stream:OUTPUT_STREAM := OUTPUT_STREAM;
-  
-Section Public
-
-  - is_connected:BOOLEAN := TRUE;
-
-  - make <-
+  - exit_true <-
   (
+    exit 0;
   );
 
-  - read_character <-
+  - exit_false <-
   (
-    std_input.read_character;
+    exit 1;
   );
 
-  - unread_character <-
+  + m_test_description :STRING := "<NO DESCRIPTION>\n";
+  + m_test_compile :BOOLEAN := TRUE;
+  + m_test_run :BOOLEAN := TRUE;
+  + m_test_compile_pattern :STRING := "";
+  + m_test_run_pattern :STRING := "";
+
+Section Public
+
+  - test <-
+  // Compile as a test
   (
-    std_input.unread_character;
   );
 
-  - push_back_flag:BOOLEAN <-
+  - test_description <-
+  // Print the description of the test
   (
-    std_input.push_back_flag
+    m_test_description.print;
+    exit_true;
   );
 
-  - last_character:CHARACTER <-
+  - test_compile <-
+  // Exit successfully if the compilation must succeed
   (
-    std_input.last_character
+    m_test_compile.if {
+      exit_true;
+    } else {
+      exit_false;
+    };
   );
 
-  - put_character c:CHARACTER <-
+  - test_run <-
+  // Exit successfully if the result of the compilation must be executed
   (
-    std_output.put_character c;
+    m_test_run.if {
+      exit_true;
+    } else {
+      exit_false;
+    };
   );
 
-  - end_of_input:BOOLEAN <-
+  - test_compile_patterns <-
+  // Regular expressions that must be found in the result of the compilation for
+  // the test to succeed
   (
-    std_input.end_of_input
+    m_test_compile_pattern.print;
+    exit_true;
   );
-  
-  - read_line_in buffer:STRING <-
+
+  - test_run_patterns <-
+  // Regular expressions that must be found in the result of the program's
+  // execution for the test to succeed
   (
-    std_input.read_line_in buffer;
+    m_test_run_pattern.print;
+    exit_true;
   );
-

-- 
Lisaac compiler



More information about the Lisaac-commits mailing list