summaryrefslogtreecommitdiff
path: root/Examples
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2022-11-23 21:12:07 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2022-11-23 21:12:07 +0000
commit5a8d58c3a761280036520f07b53f47d5856f9171 (patch)
tree29dcc114e7cfe8b3c008c1303410a57e6a98c400 /Examples
parenteef3de65749d9411d61b38f0b3d7cc7aa52226a2 (diff)
parent1dd31446ce5e24901b9671927a098e23e40c4651 (diff)
downloadswig-5a8d58c3a761280036520f07b53f47d5856f9171.tar.gz
Merge branch 'rtests2'
* rtests2: more r tests more r tests added testcase pointer_reference [PHP] Update docs for removal of -noproxy in SWIG 4.1.0 Conflicts: CHANGES.current
Diffstat (limited to 'Examples')
-rw-r--r--Examples/test-suite/r/pointer_reference_runme.R24
-rw-r--r--Examples/test-suite/r/template_class_reuse_name_runme.R52
-rw-r--r--Examples/test-suite/r/template_classes_runme.R57
-rw-r--r--Examples/test-suite/r/template_default_arg_overloaded_extend_runme.R25
-rw-r--r--Examples/test-suite/r/template_default_arg_overloaded_runme.R53
-rw-r--r--Examples/test-suite/r/template_ref_type_runme.R14
6 files changed, 225 insertions, 0 deletions
diff --git a/Examples/test-suite/r/pointer_reference_runme.R b/Examples/test-suite/r/pointer_reference_runme.R
new file mode 100644
index 000000000..4a2a7ea1b
--- /dev/null
+++ b/Examples/test-suite/r/pointer_reference_runme.R
@@ -0,0 +1,24 @@
+clargs <- commandArgs(trailing=TRUE)
+source(file.path(clargs[1], "unittest.R"))
+#source("unittest.R")
+
+dyn.load(paste("pointer_reference", .Platform$dynlib.ext, sep=""))
+source("pointer_reference.R")
+cacheMetaData(1)
+
+
+s = Struct_value_get(Struct_pInstance_get())
+unittest(s, 10)
+
+ss = Struct(20)
+Struct_pInstance_set(ss)
+s = Struct_value_get(Struct_pInstance_get())
+unittest(s, 20)
+
+s = overloading(1)
+unittest(s, 111)
+
+s = overloading(ss)
+unittest(s, 222)
+
+
diff --git a/Examples/test-suite/r/template_class_reuse_name_runme.R b/Examples/test-suite/r/template_class_reuse_name_runme.R
new file mode 100644
index 000000000..256482213
--- /dev/null
+++ b/Examples/test-suite/r/template_class_reuse_name_runme.R
@@ -0,0 +1,52 @@
+clargs <- commandArgs(trailing=TRUE)
+source(file.path(clargs[1], "unittest.R"))
+#source("unittest.R")
+
+dyn.load(paste("template_class_reuse_name", .Platform$dynlib.ext, sep=""))
+source("template_class_reuse_name.R")
+cacheMetaData(1)
+
+
+
+
+
+Bool1()$tt()
+Bool1False()$ff()
+
+Bool2()$tt()
+Bool2False()$ff()
+
+Bool3()$tt()
+Bool3False()$ff()
+
+Bool4()$tt()
+Bool4False()$ff()
+
+
+BoolForward1()$tt()
+BoolForward1False()$ff()
+
+BoolForward2()$tt()
+BoolForward2False()$ff()
+
+BoolForward3()$tt()
+BoolForward3False()$ff()
+
+BoolForward4()$tt()
+BoolForward4False()$ff()
+
+
+IntBool1()$tt()
+IntBool1False()$ff()
+
+IntBool2()$tt()
+IntBool2False()$ff()
+
+IntBool3()$tt()
+IntBool3False()$ff()
+
+IntBool4()$tt()
+IntBool4False()$ff()
+
+Duplicate2_0_n(Duplicate2_0())
+Duplicate3_n(Duplicate3())
diff --git a/Examples/test-suite/r/template_classes_runme.R b/Examples/test-suite/r/template_classes_runme.R
new file mode 100644
index 000000000..e40dfd4cc
--- /dev/null
+++ b/Examples/test-suite/r/template_classes_runme.R
@@ -0,0 +1,57 @@
+
+clargs <- commandArgs(trailing=TRUE)
+source(file.path(clargs[1], "unittest.R"))
+#source("unittest.R")
+
+dyn.load(paste("template_classes", .Platform$dynlib.ext, sep=""))
+source("template_classes.R")
+cacheMetaData(1)
+
+
+# This test is just testing incorrect number of arguments/parameters checking
+
+point = PointInt()
+rectangle = RectangleInt()
+
+p = RectangleInt_getPoint(rectangle)
+unittest(PointInt_getX(p), 0)
+
+RectangleInt_setPoint(rectangle, point)
+
+unittest(RectangleInt_static_noargs(), 0)
+unittest(RectangleInt_static_onearg(12), 12)
+
+
+argCheckFailed = F
+try({
+ RectangleInt_setPoint(rectangle)
+ argCheckFailed = T
+}, silent=T)
+unittest(argCheckFailed, F)
+
+
+argCheckFailed = F
+try({
+ RectangleInt_getPoint(rectangle, 0, .copy = F)
+ argCheckFailed = T
+}, silent=T)
+unittest(argCheckFailed, F)
+
+
+argCheckFailed = F
+try({
+ RectangleInt_static_noargs(123, .copy = F)
+ argCheckFailed = T
+}, silent=T)
+unittest(argCheckFailed, F)
+
+
+
+argCheckFailed = F
+try({
+ RectangleInt_static_onearg()
+ argCheckFailed = T
+}, silent=T)
+unittest(argCheckFailed, F)
+
+
diff --git a/Examples/test-suite/r/template_default_arg_overloaded_extend_runme.R b/Examples/test-suite/r/template_default_arg_overloaded_extend_runme.R
new file mode 100644
index 000000000..3ec4eb3e9
--- /dev/null
+++ b/Examples/test-suite/r/template_default_arg_overloaded_extend_runme.R
@@ -0,0 +1,25 @@
+clargs <- commandArgs(trailing=TRUE)
+source(file.path(clargs[1], "unittest.R"))
+#source("unittest.R")
+
+dyn.load(paste("template_default_arg_overloaded_extend", .Platform$dynlib.ext, sep=""))
+source("template_default_arg_overloaded_extend.R")
+cacheMetaData(1)
+
+
+
+
+rs = ResultSet()
+
+unittest(rs$go_get_method(0, SearchPoint()), -1)
+unittest(rs$go_get_method(0, SearchPoint(), 100), 100)
+
+unittest(rs$go_get_template(0, SearchPoint()), -2)
+unittest(rs$go_get_template(0, SearchPoint(), 100), 100)
+
+unittest(rs$over(), "over(int)")
+unittest(rs$over(10), "over(int)")
+unittest(rs$over(SearchPoint()), "over(giai2::SearchPoint, int)")
+unittest(rs$over(SearchPoint(), 10), "over(giai2::SearchPoint, int)")
+unittest(rs$over(T, SearchPoint()), "over(bool, gaia2::SearchPoint, int)")
+unittest(rs$over(T, SearchPoint(), 10), "over(bool, gaia2::SearchPoint, int)")
diff --git a/Examples/test-suite/r/template_default_arg_overloaded_runme.R b/Examples/test-suite/r/template_default_arg_overloaded_runme.R
new file mode 100644
index 000000000..bf9272d3c
--- /dev/null
+++ b/Examples/test-suite/r/template_default_arg_overloaded_runme.R
@@ -0,0 +1,53 @@
+
+clargs <- commandArgs(trailing=TRUE)
+source(file.path(clargs[1], "unittest.R"))
+#source("unittest.R")
+
+dyn.load(paste("template_default_arg_overloaded", .Platform$dynlib.ext, sep=""))
+source("template_default_arg_overloaded.R")
+cacheMetaData(1)
+
+
+
+
+pl = PropertyList()
+unittest(1, pl$setInt("int", 10))
+unittest(1, pl$setInt("int", 10, F))
+
+unittest(2, pl$set("int", pl))
+unittest(2, pl$set("int", pl, F))
+
+unittest(3, pl$setInt("int", 10, "int"))
+unittest(3, pl$setInt("int", 10, "int", F))
+
+
+pl = PropertyListGlobal()
+unittest(1, pl$setIntGlobal("int", 10))
+unittest(1, pl$setIntGlobal("int", 10, F))
+
+unittest(2, pl$set("int", pl))
+unittest(2, pl$set("int", pl, F))
+
+unittest(3, pl$setIntGlobal("int", 10, "int"))
+unittest(3, pl$setIntGlobal("int", 10, "int", F))
+
+
+unittest(1, GoopIntGlobal(10))
+unittest(1, GoopIntGlobal(10, T))
+
+unittest(2, goopGlobal(3))
+unittest(2, goopGlobal())
+
+unittest(3, GoopIntGlobal("int", F))
+unittest(3, GoopIntGlobal("int"))
+
+
+unittest(1, GoopInt(10))
+unittest(1, GoopInt(10, T))
+
+unittest(2, goop(3))
+unittest(2, goop())
+
+unittest(3, GoopInt("int", F))
+unittest(3, GoopInt("int"))
+
diff --git a/Examples/test-suite/r/template_ref_type_runme.R b/Examples/test-suite/r/template_ref_type_runme.R
new file mode 100644
index 000000000..2565019d7
--- /dev/null
+++ b/Examples/test-suite/r/template_ref_type_runme.R
@@ -0,0 +1,14 @@
+
+clargs <- commandArgs(trailing=TRUE)
+source(file.path(clargs[1], "unittest.R"))
+#source("unittest.R")
+
+dyn.load(paste("template_ref_type", .Platform$dynlib.ext, sep=""))
+source("template_ref_type.R")
+cacheMetaData(1)
+
+xr = XC()
+y = Y()
+
+unittest(Y_find(y, xr), FALSE)
+