icode: add automatic tests for virtual type parameters in methods
authorJean Privat <jean@pryen.org>
Fri, 25 Nov 2011 14:17:30 +0000 (09:17 -0500)
committerJean Privat <jean@pryen.org>
Fri, 25 Nov 2011 16:02:05 +0000 (11:02 -0500)
Tests are added by the method generate_empty_iroutine of MMSignature
Not that tests are systematic even in the safe case (call on self).

Some unsafe places remain, like parameters in closure definitions or
in unsafe assignments.

test_variance_params is updated to reflect the fix.

Signed-off-by: Jean Privat <jean@pryen.org>

13 files changed:
src/icode/icode_builder.nit
tests/sav/test_variance_param_alt1.fail [deleted file]
tests/sav/test_variance_param_alt1.sav [new file with mode: 0644]
tests/sav/test_variance_param_alt2.fail [deleted file]
tests/sav/test_variance_param_alt2.sav [new file with mode: 0644]
tests/sav/test_variance_param_alt3.fail [deleted file]
tests/sav/test_variance_param_alt3.sav [new file with mode: 0644]
tests/sav/test_variance_param_alt4.fail [deleted file]
tests/sav/test_variance_param_alt4.sav [new file with mode: 0644]
tests/sav/test_variance_param_alt5.fail [deleted file]
tests/sav/test_variance_param_alt5.sav [new file with mode: 0644]
tests/sav/test_variance_param_alt6.fail [deleted file]
tests/sav/test_variance_param_alt6.sav [new file with mode: 0644]

index c50ab6a..7f37b75 100644 (file)
@@ -244,6 +244,14 @@ redef class MMSignature
                        end
                        iroutine.closure_decls = clos
                end
+               # Add automatic test for virtual types
+               var icb = new ICodeBuilder(recv.mmmodule, iroutine)
+               for i in [0..arity[ do
+                       var t = self[i]
+                       if t isa MMVirtualType then
+                               icb.add_type_cast(args[i+1], t)
+                       end
+               end
                return iroutine
        end
 
@@ -268,6 +276,7 @@ redef class MMSignature
                        end
                        iroutine.closure_decls = clos
                end
+               # TODO: add automatic test for virtual types?
                return iroutine
        end
 end
diff --git a/tests/sav/test_variance_param_alt1.fail b/tests/sav/test_variance_param_alt1.fail
deleted file mode 100644 (file)
index 329511a..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-AB5
-B5
-5
-AB5
-5
-5
-5
-5
-5
-B5
-5
-5
-5
-5
-5
-5
-5
-5
diff --git a/tests/sav/test_variance_param_alt1.sav b/tests/sav/test_variance_param_alt1.sav
new file mode 100644 (file)
index 0000000..92b4d63
--- /dev/null
@@ -0,0 +1,4 @@
+AB5
+B5
+5
+Cast failed (alt/test_variance_param_alt1.nit)
diff --git a/tests/sav/test_variance_param_alt2.fail b/tests/sav/test_variance_param_alt2.fail
deleted file mode 100644 (file)
index 4ac4e3c..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-AB5
-B5
-5
-B5
-B5
-5
-5
-5
-5
-B5
-5
-5
-5
-5
-5
-5
-5
-5
diff --git a/tests/sav/test_variance_param_alt2.sav b/tests/sav/test_variance_param_alt2.sav
new file mode 100644 (file)
index 0000000..fdbf394
--- /dev/null
@@ -0,0 +1,5 @@
+AB5
+B5
+5
+B5
+Cast failed (alt/test_variance_param_alt2.nit)
diff --git a/tests/sav/test_variance_param_alt3.fail b/tests/sav/test_variance_param_alt3.fail
deleted file mode 100644 (file)
index fab8897..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-AB5
-B5
-5
-B5
-5
-5
-A5
-5
-5
-B5
-5
-5
-5
-5
-5
-5
-5
-5
diff --git a/tests/sav/test_variance_param_alt3.sav b/tests/sav/test_variance_param_alt3.sav
new file mode 100644 (file)
index 0000000..f0fdbc0
--- /dev/null
@@ -0,0 +1,7 @@
+AB5
+B5
+5
+B5
+5
+5
+Cast failed (alt/test_variance_param_alt3.nit)
diff --git a/tests/sav/test_variance_param_alt4.fail b/tests/sav/test_variance_param_alt4.fail
deleted file mode 100644 (file)
index bd44b47..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-AB5
-B5
-5
-B5
-5
-5
-B5
-5
-5
-B5
-5
-5
-5
-5
-5
-5
-5
-5
diff --git a/tests/sav/test_variance_param_alt4.sav b/tests/sav/test_variance_param_alt4.sav
new file mode 100644 (file)
index 0000000..3e39281
--- /dev/null
@@ -0,0 +1,7 @@
+AB5
+B5
+5
+B5
+5
+5
+Cast failed (alt/test_variance_param_alt4.nit)
diff --git a/tests/sav/test_variance_param_alt5.fail b/tests/sav/test_variance_param_alt5.fail
deleted file mode 100644 (file)
index 7d83e9e..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-AB5
-B5
-5
-B5
-5
-5
-5
-B5
-5
-B5
-5
-5
-5
-5
-5
-5
-5
-5
diff --git a/tests/sav/test_variance_param_alt5.sav b/tests/sav/test_variance_param_alt5.sav
new file mode 100644 (file)
index 0000000..88c3c73
--- /dev/null
@@ -0,0 +1,8 @@
+AB5
+B5
+5
+B5
+5
+5
+5
+Cast failed (alt/test_variance_param_alt5.nit)
diff --git a/tests/sav/test_variance_param_alt6.fail b/tests/sav/test_variance_param_alt6.fail
deleted file mode 100644 (file)
index 7494b82..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-AB5
-B5
-5
-B5
-5
-5
-5
-5
-5
-B5
-5
-5
-B5
-5
-5
-5
-5
-5
diff --git a/tests/sav/test_variance_param_alt6.sav b/tests/sav/test_variance_param_alt6.sav
new file mode 100644 (file)
index 0000000..eab7e90
--- /dev/null
@@ -0,0 +1,13 @@
+AB5
+B5
+5
+B5
+5
+5
+5
+5
+5
+B5
+5
+5
+Cast failed (alt/test_variance_param_alt6.nit)