Merge branch 'typecheck-null-nonpointers'
* typecheck-null-nonpointers: Fix overloading for non-pointers and NULL - MzScheme Overloading for non-pointers and NULL - Chicken Fix overloading for non-pointers and NULL - Scilab Fix overloading for non-pointers and NULL - R Fix overloading for non-pointers and NULL - Php Fix overloading for non-pointers and NULL - Octave Fix overloading for non-pointers and NULL - Lua Overloading for non-pointers and NULL - Javascript Fix overloading for non-pointers and NULL - Guile Fix overloading for non-pointers and NULL - Tcl Fix overloading for non-pointers and NULL - Perl Fix overloading for non-pointers and NULL - Ruby Add test for overloading and NULL Correct Python implicitconv code Fix typecheck typemaps for non-pointers and NULL
This commit is contained in:
commit
6a80ec314a
40 changed files with 685 additions and 87 deletions
|
|
@ -340,6 +340,7 @@ CPP_TEST_CASES += \
|
|||
overload_extend \
|
||||
overload_method \
|
||||
overload_numeric \
|
||||
overload_null \
|
||||
overload_polymorphic \
|
||||
overload_rename \
|
||||
overload_return_type \
|
||||
|
|
|
|||
53
Examples/test-suite/guile/overload_null_runme.scm
Normal file
53
Examples/test-suite/guile/overload_null_runme.scm
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
|
||||
;; Guile modules (namespaces) but simply put all the bindings into the
|
||||
;; current module. That's enough for such a simple test.
|
||||
(dynamic-call "scm_init_overload_null_module" (dynamic-link "./liboverload_null"))
|
||||
|
||||
(define-macro (check form)
|
||||
`(if (not ,form)
|
||||
(error "Check failed: " ',form)))
|
||||
|
||||
(define (=~ a b)
|
||||
(< (abs (- a b)) 1e-8))
|
||||
|
||||
(define o (new-Overload))
|
||||
(define x (new-X))
|
||||
|
||||
(check (=~ 1 (Overload-byval1 o x)))
|
||||
(check (=~ 2 (Overload-byval1 o #nil)))
|
||||
|
||||
(check (=~ 3 (Overload-byval2 o #nil)))
|
||||
(check (=~ 4 (Overload-byval2 o x)))
|
||||
|
||||
(check (=~ 5 (Overload-byref1 o x)))
|
||||
(check (=~ 6 (Overload-byref1 o #nil)))
|
||||
|
||||
(check (=~ 7 (Overload-byref2 o #nil)))
|
||||
(check (=~ 8 (Overload-byref2 o x)))
|
||||
|
||||
(check (=~ 9 (Overload-byconstref1 o x)))
|
||||
(check (=~ 10 (Overload-byconstref1 o #nil)))
|
||||
|
||||
(check (=~ 11 (Overload-byconstref2 o #nil)))
|
||||
(check (=~ 12 (Overload-byconstref2 o x)))
|
||||
|
||||
; const pointer references
|
||||
; No SWIGTYPE *const& typemaps for Guile yet
|
||||
;(check (=~ 13 (Overload-byval1cpr o x)))
|
||||
;(check (=~ 14 (Overload-byval1cpr o #nil)))
|
||||
|
||||
;(check (=~ 15 (Overload-byval2cpr o #nil)))
|
||||
;(check (=~ 16 (Overload-byval2cpr o x)))
|
||||
|
||||
; forward class declaration
|
||||
(check (=~ 17 (Overload-byval1forwardptr o x)))
|
||||
(check (=~ 18 (Overload-byval1forwardptr o #nil)))
|
||||
|
||||
(check (=~ 19 (Overload-byval2forwardptr o #nil)))
|
||||
(check (=~ 20 (Overload-byval2forwardptr o x)))
|
||||
|
||||
(check (=~ 21 (Overload-byval1forwardref o x)))
|
||||
|
||||
(check (=~ 22 (Overload-byval2forwardref o x)))
|
||||
|
||||
(exit 0)
|
||||
49
Examples/test-suite/javascript/overload_null_runme.js
Normal file
49
Examples/test-suite/javascript/overload_null_runme.js
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
// There are no typecheck typemaps in Javascript yet, so most of this test
|
||||
// does not actually worked - the check functions have thus been commented out.
|
||||
var overload_null = require("overload_null");
|
||||
|
||||
var check = function(expected, actual) {
|
||||
if (expected !== actual) {
|
||||
throw new Error(a + " does not equal " + b);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var o = new overload_null.Overload();
|
||||
var x = new overload_null.X();
|
||||
|
||||
check(1, o.byval1(x));
|
||||
// check(2, o.byval1(null));
|
||||
|
||||
// check(3, o.byval2(null));
|
||||
check(4, o.byval2(x));
|
||||
|
||||
check(5, o.byref1(x));
|
||||
// check(6, o.byref1(null));
|
||||
|
||||
// check(7, o.byref2(null));
|
||||
check(8, o.byref2(x));
|
||||
|
||||
check(9, o.byconstref1(x));
|
||||
// check(10, o.byconstref1(null));
|
||||
|
||||
// check(11, o.byconstref2(null));
|
||||
check(12, o.byconstref2(x));
|
||||
|
||||
// const pointer references
|
||||
check(13, o.byval1cpr(x));
|
||||
// check(14, o.byval1cpr(null));
|
||||
|
||||
// check(15, o.byval2cpr(null));
|
||||
check(16, o.byval2cpr(x));
|
||||
|
||||
// forward class declaration
|
||||
check(17, o.byval1forwardptr(x));
|
||||
// check(18, o.byval1forwardptr(null));
|
||||
|
||||
// check(19, o.byval2forwardptr(null));
|
||||
check(20, o.byval2forwardptr(x));
|
||||
|
||||
check(21, o.byval1forwardref(x));
|
||||
|
||||
check(22, o.byval2forwardref(x));
|
||||
41
Examples/test-suite/lua/overload_null_runme.lua
Normal file
41
Examples/test-suite/lua/overload_null_runme.lua
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
require("import") -- the import fn
|
||||
import("overload_null") -- import lib into global
|
||||
|
||||
o = overload_null.Overload()
|
||||
x = overload_null.X()
|
||||
|
||||
assert(1 == o:byval1(x))
|
||||
assert(2 == o:byval1(nil))
|
||||
|
||||
assert(3 == o:byval2(nil))
|
||||
assert(4 == o:byval2(x))
|
||||
|
||||
assert(5 == o:byref1(x))
|
||||
assert(6 == o:byref1(nil))
|
||||
|
||||
assert(7 == o:byref2(nil))
|
||||
assert(8 == o:byref2(x))
|
||||
|
||||
assert(9 == o:byconstref1(x))
|
||||
assert(10 == o:byconstref1(nil))
|
||||
|
||||
assert(11 == o:byconstref2(nil))
|
||||
assert(12 == o:byconstref2(x))
|
||||
|
||||
-- const pointer references
|
||||
assert(13 == o:byval1cpr(x))
|
||||
assert(14 == o:byval1cpr(nil))
|
||||
|
||||
assert(15 == o:byval2cpr(nil))
|
||||
assert(16 == o:byval2cpr(x))
|
||||
|
||||
-- forward class declaration
|
||||
assert(17 == o:byval1forwardptr(x))
|
||||
assert(18 == o:byval1forwardptr(nil))
|
||||
|
||||
assert(19 == o:byval2forwardptr(nil))
|
||||
assert(20 == o:byval2forwardptr(x))
|
||||
|
||||
assert(21 == o:byval1forwardref(x))
|
||||
|
||||
assert(22 == o:byval2forwardref(x))
|
||||
52
Examples/test-suite/octave/overload_null_runme.m
Normal file
52
Examples/test-suite/octave/overload_null_runme.m
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
# do not dump Octave core
|
||||
if exist("crash_dumps_octave_core", "builtin")
|
||||
crash_dumps_octave_core(0);
|
||||
endif
|
||||
|
||||
overload_null
|
||||
|
||||
function check(a, b)
|
||||
if (a != b)
|
||||
error("%i does not equal %i", a, b);
|
||||
endif
|
||||
end
|
||||
|
||||
o = Overload();
|
||||
x = X();
|
||||
null = []; # NULL pointer
|
||||
|
||||
check(1, o.byval1(x));
|
||||
check(2, o.byval1(null));
|
||||
|
||||
check(3, o.byval2(null));
|
||||
check(4, o.byval2(x));
|
||||
|
||||
check(5, o.byref1(x));
|
||||
check(6, o.byref1(null));
|
||||
|
||||
check(7, o.byref2(null));
|
||||
check(8, o.byref2(x));
|
||||
|
||||
check(9, o.byconstref1(x));
|
||||
check(10, o.byconstref1(null));
|
||||
|
||||
check(11, o.byconstref2(null));
|
||||
check(12, o.byconstref2(x));
|
||||
|
||||
# const pointer references
|
||||
check(13, o.byval1cpr(x));
|
||||
check(14, o.byval1cpr(null));
|
||||
|
||||
check(15, o.byval2cpr(null));
|
||||
check(16, o.byval2cpr(x));
|
||||
|
||||
# forward class declaration
|
||||
check(17, o.byval1forwardptr(x));
|
||||
check(18, o.byval1forwardptr(null));
|
||||
|
||||
check(19, o.byval2forwardptr(null));
|
||||
check(20, o.byval2forwardptr(x));
|
||||
|
||||
check(21, o.byval1forwardref(x));
|
||||
|
||||
check(22, o.byval2forwardref(x));
|
||||
52
Examples/test-suite/overload_null.i
Normal file
52
Examples/test-suite/overload_null.i
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
%module overload_null
|
||||
|
||||
%{
|
||||
struct F {};
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
struct X {};
|
||||
struct Y {};
|
||||
struct F;
|
||||
|
||||
struct Overload {
|
||||
int byval1(X x) { return 1; }
|
||||
int byval1(Y* y) { return 2; }
|
||||
|
||||
int byval2(Y* y) { return 3; }
|
||||
int byval2(X x) { return 4; }
|
||||
|
||||
int byref1(X& x) { return 5; }
|
||||
int byref1(Y* y) { return 6; }
|
||||
|
||||
int byref2(Y* y) { return 7; }
|
||||
int byref2(X& x) { return 8; }
|
||||
|
||||
int byconstref1(const X& x) { return 9; }
|
||||
int byconstref1(Y* y) { return 10; }
|
||||
|
||||
int byconstref2(Y* y) { return 11; }
|
||||
int byconstref2(const X& x) { return 12; }
|
||||
|
||||
// const pointer references
|
||||
int byval1cpr(X x) { return 13; }
|
||||
int byval1cpr(Y*const& y) { return 14; }
|
||||
|
||||
int byval2cpr(Y*const& y) { return 15; }
|
||||
int byval2cpr(X x) { return 16; }
|
||||
|
||||
// forward class declaration
|
||||
int byval1forwardptr(X x) { return 17; }
|
||||
int byval1forwardptr(F* f) { return 18; }
|
||||
|
||||
int byval2forwardptr(F* f) { return 19; }
|
||||
int byval2forwardptr(X x) { return 20; }
|
||||
|
||||
int byval1forwardref(X x) { return 21; }
|
||||
int byval1forwardref(F& f) { return -21; }
|
||||
|
||||
int byval2forwardref(F& f) { return -22; }
|
||||
int byval2forwardref(X x) { return 22; }
|
||||
|
||||
};
|
||||
%}
|
||||
44
Examples/test-suite/perl5/overload_null_runme.pl
Normal file
44
Examples/test-suite/perl5/overload_null_runme.pl
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 24;
|
||||
BEGIN { use_ok('overload_null') }
|
||||
require_ok('overload_null');
|
||||
|
||||
my $o = new overload_null::Overload();
|
||||
my $x = new overload_null::X();
|
||||
|
||||
is(1, $o->byval1($x));
|
||||
is(2, $o->byval1(undef));
|
||||
|
||||
is(3, $o->byval2(undef));
|
||||
is(4, $o->byval2($x));
|
||||
|
||||
is(5, $o->byref1($x));
|
||||
is(6, $o->byref1(undef));
|
||||
|
||||
is(7, $o->byref2(undef));
|
||||
is(8, $o->byref2($x));
|
||||
|
||||
is(9, $o->byconstref1($x));
|
||||
is(10, $o->byconstref1(undef));
|
||||
|
||||
is(11, $o->byconstref2(undef));
|
||||
is(12, $o->byconstref2($x));
|
||||
|
||||
# const pointer references
|
||||
is(13, $o->byval1cpr($x));
|
||||
is(14, $o->byval1cpr(undef));
|
||||
|
||||
is(15, $o->byval2cpr(undef));
|
||||
is(16, $o->byval2cpr($x));
|
||||
|
||||
# forward class declaration
|
||||
is(17, $o->byval1forwardptr($x));
|
||||
is(18, $o->byval1forwardptr(undef));
|
||||
|
||||
is(19, $o->byval2forwardptr(undef));
|
||||
is(20, $o->byval2forwardptr($x));
|
||||
|
||||
is(21, $o->byval1forwardref($x));
|
||||
|
||||
is(22, $o->byval2forwardref($x));
|
||||
46
Examples/test-suite/php/overload_null_runme.php
Normal file
46
Examples/test-suite/php/overload_null_runme.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "overload_null.php";
|
||||
|
||||
$o = new Overload();
|
||||
$x = new X();
|
||||
|
||||
check::equal(1, $o->byval1($x), "test 1");
|
||||
check::equal(2, $o->byval1(null), "test 2");
|
||||
|
||||
check::equal(3, $o->byval2(null), "test 3");
|
||||
check::equal(4, $o->byval2($x), "test 4");
|
||||
|
||||
check::equal(5, $o->byref1($x), "test 5");
|
||||
check::equal(6, $o->byref1(null), "test 6");
|
||||
|
||||
check::equal(7, $o->byref2(null), "test 7");
|
||||
check::equal(8, $o->byref2($x), "test 8");
|
||||
|
||||
check::equal(9, $o->byconstref1($x), "test 9");
|
||||
check::equal(10, $o->byconstref1(null), "test 10");
|
||||
|
||||
check::equal(11, $o->byconstref2(null), "test 11");
|
||||
check::equal(12, $o->byconstref2($x), "test 12");
|
||||
|
||||
# const pointer references
|
||||
check::equal(13, $o->byval1cpr($x), "test 13");
|
||||
check::equal(14, $o->byval1cpr(null), "test 14");
|
||||
|
||||
check::equal(15, $o->byval2cpr(null), "test 15");
|
||||
check::equal(16, $o->byval2cpr($x), "test 16");
|
||||
|
||||
# forward class declaration
|
||||
check::equal(17, $o->byval1forwardptr($x), "test 17");
|
||||
check::equal(18, $o->byval1forwardptr(null), "test 18");
|
||||
|
||||
check::equal(19, $o->byval2forwardptr(null), "test 19");
|
||||
check::equal(20, $o->byval2forwardptr($x), "test 20");
|
||||
|
||||
check::equal(21, $o->byval1forwardref($x), "test 21");
|
||||
|
||||
check::equal(22, $o->byval2forwardref($x), "test 22");
|
||||
|
||||
check::done();
|
||||
?>
|
||||
|
|
@ -13,15 +13,7 @@ check(1, A(1).get())
|
|||
check(2, A(1.0).get())
|
||||
check(3, A(B()).get())
|
||||
check(4, A("hello").get())
|
||||
try:
|
||||
check(3, A(None).get())
|
||||
raise RuntimeError
|
||||
except ValueError:
|
||||
# ValueError: invalid null reference in method 'new_A', argument 1 of type 'B const &'
|
||||
# Arguably A(char *) should be chosen, but there is a bug to do with None passed to methods overloaded by value,
|
||||
# references and pointers to different types, where pointers ought to be
|
||||
# given a slightly higher precedence.
|
||||
pass
|
||||
check(4, A(None).get())
|
||||
|
||||
check(1, get(1))
|
||||
check(2, get(1.0))
|
||||
|
|
|
|||
44
Examples/test-suite/python/overload_null_runme.py
Normal file
44
Examples/test-suite/python/overload_null_runme.py
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
from overload_null import *
|
||||
|
||||
def check(a, b):
|
||||
if a != b:
|
||||
raise RuntimeError(str(a) + " does not equal " + str(b))
|
||||
|
||||
o = Overload()
|
||||
x = X()
|
||||
|
||||
check(1, o.byval1(x))
|
||||
check(2, o.byval1(None))
|
||||
|
||||
check(3, o.byval2(None))
|
||||
check(4, o.byval2(x))
|
||||
|
||||
check(5, o.byref1(x))
|
||||
check(6, o.byref1(None))
|
||||
|
||||
check(7, o.byref2(None))
|
||||
check(8, o.byref2(x))
|
||||
|
||||
check(9, o.byconstref1(x))
|
||||
check(10, o.byconstref1(None))
|
||||
|
||||
check(11, o.byconstref2(None))
|
||||
check(12, o.byconstref2(x))
|
||||
|
||||
# const pointer references
|
||||
check(13, o.byval1cpr(x))
|
||||
check(14, o.byval1cpr(None))
|
||||
|
||||
check(15, o.byval2cpr(None))
|
||||
check(16, o.byval2cpr(x))
|
||||
|
||||
# forward class declaration
|
||||
check(17, o.byval1forwardptr(x))
|
||||
check(18, o.byval1forwardptr(None))
|
||||
|
||||
check(19, o.byval2forwardptr(None))
|
||||
check(20, o.byval2forwardptr(x))
|
||||
|
||||
check(21, o.byval1forwardref(x))
|
||||
|
||||
check(22, o.byval2forwardref(x))
|
||||
49
Examples/test-suite/r/overload_null_runme.R
Normal file
49
Examples/test-suite/r/overload_null_runme.R
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
clargs <- commandArgs(trailing=TRUE)
|
||||
source(file.path(clargs[1], "unittest.R"))
|
||||
|
||||
dyn.load(paste("overload_null", .Platform$dynlib.ext, sep=""))
|
||||
source("overload_null.R")
|
||||
cacheMetaData(1)
|
||||
|
||||
o <- Overload()
|
||||
x <- X()
|
||||
|
||||
unittest(1, o$byval1(x))
|
||||
unittest(2, o$byval1(NULL))
|
||||
|
||||
unittest(3, o$byval2(NULL))
|
||||
unittest(4, o$byval2(x))
|
||||
|
||||
unittest(5, o$byref1(x))
|
||||
unittest(6, o$byref1(NULL))
|
||||
|
||||
unittest(7, o$byref2(NULL))
|
||||
unittest(8, o$byref2(x))
|
||||
|
||||
unittest(9, o$byconstref1(x))
|
||||
unittest(10, o$byconstref1(NULL))
|
||||
|
||||
unittest(11, o$byconstref2(NULL))
|
||||
unittest(12, o$byconstref2(x))
|
||||
|
||||
# const pointer references
|
||||
# No SWIGTYPE *const& typemaps for R yet
|
||||
#unittest(13, o$byval1cpr(x))
|
||||
#unittest(14, o$byval1cpr(NULL))
|
||||
|
||||
#unittest(15, o$byval2cpr(NULL))
|
||||
#unittest(16, o$byval2cpr(x))
|
||||
|
||||
# forward class declaration
|
||||
unittest(17, o$byval1forwardptr(x))
|
||||
unittest(18, o$byval1forwardptr(NULL))
|
||||
|
||||
unittest(19, o$byval2forwardptr(NULL))
|
||||
unittest(20, o$byval2forwardptr(x))
|
||||
|
||||
unittest(21, o$byval1forwardref(x))
|
||||
|
||||
unittest(22, o$byval2forwardref(x))
|
||||
|
||||
q(save="no")
|
||||
|
||||
52
Examples/test-suite/ruby/overload_null_runme.rb
Normal file
52
Examples/test-suite/ruby/overload_null_runme.rb
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#!/usr/bin/env ruby
|
||||
#
|
||||
# Put script description here.
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
require 'swig_assert'
|
||||
require 'overload_null'
|
||||
|
||||
include Overload_null
|
||||
|
||||
o = Overload.new
|
||||
x = X.new
|
||||
|
||||
swig_assert(1 == o.byval1(x))
|
||||
swig_assert(2 == o.byval1(nil))
|
||||
|
||||
swig_assert(3 == o.byval2(nil))
|
||||
swig_assert(4 == o.byval2(x))
|
||||
|
||||
swig_assert(5 == o.byref1(x))
|
||||
swig_assert(6 == o.byref1(nil))
|
||||
|
||||
swig_assert(7 == o.byref2(nil))
|
||||
swig_assert(8 == o.byref2(x))
|
||||
|
||||
swig_assert(9 == o.byconstref1(x))
|
||||
swig_assert(10 == o.byconstref1(nil))
|
||||
|
||||
swig_assert(11 == o.byconstref2(nil))
|
||||
swig_assert(12 == o.byconstref2(x))
|
||||
|
||||
# const pointer references
|
||||
swig_assert(13 == o.byval1cpr(x))
|
||||
swig_assert(14 == o.byval1cpr(nil))
|
||||
|
||||
swig_assert(15 == o.byval2cpr(nil))
|
||||
swig_assert(16 == o.byval2cpr(x))
|
||||
|
||||
# forward class declaration
|
||||
swig_assert(17 == o.byval1forwardptr(x))
|
||||
swig_assert(18 == o.byval1forwardptr(nil))
|
||||
|
||||
swig_assert(19 == o.byval2forwardptr(nil))
|
||||
swig_assert(20 == o.byval2forwardptr(x))
|
||||
|
||||
swig_assert(21 == o.byval1forwardref(x))
|
||||
|
||||
swig_assert(22 == o.byval2forwardref(x))
|
||||
45
Examples/test-suite/scilab/overload_null_runme.sci
Normal file
45
Examples/test-suite/scilab/overload_null_runme.sci
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
exec("swigtest.start", -1);
|
||||
|
||||
NULL = SWIG_ptr(0);
|
||||
|
||||
o = new_Overload();
|
||||
x = new_X();
|
||||
|
||||
checkequal(1, Overload_byval1(o, x), "test 1");
|
||||
checkequal(2, Overload_byval1(o, NULL), "test 2");
|
||||
|
||||
checkequal(3, Overload_byval2(o, NULL), "test 3");
|
||||
checkequal(4, Overload_byval2(o, x), "test 4");
|
||||
|
||||
checkequal(5, Overload_byref1(o, x), "test 5");
|
||||
checkequal(6, Overload_byref1(o, NULL), "test 6");
|
||||
|
||||
checkequal(7, Overload_byref2(o, NULL), "test 7");
|
||||
checkequal(8, Overload_byref2(o, x), "test 8");
|
||||
|
||||
checkequal(9, Overload_byconstref1(o, x), "test 9");
|
||||
checkequal(10, Overload_byconstref1(o, NULL), "test 10");
|
||||
|
||||
checkequal(11, Overload_byconstref2(o, NULL), "test 11");
|
||||
checkequal(12, Overload_byconstref2(o, x), "test 12");
|
||||
|
||||
// const pointer references
|
||||
checkequal(13, Overload_byval1cpr(o, x), "test 13");
|
||||
checkequal(14, Overload_byval1cpr(o, NULL), "test 14");
|
||||
|
||||
checkequal(15, Overload_byval2cpr(o, NULL), "test 15");
|
||||
checkequal(16, Overload_byval2cpr(o, x), "test 16");
|
||||
|
||||
// forward class declaration
|
||||
checkequal(17, Overload_byval1forwardptr(o, x), "test 17");
|
||||
checkequal(18, Overload_byval1forwardptr(o, NULL), "test 18");
|
||||
|
||||
checkequal(19, Overload_byval2forwardptr(o, NULL), "test 19");
|
||||
checkequal(20, Overload_byval2forwardptr(o, x), "test 20");
|
||||
|
||||
checkequal(21, Overload_byval1forwardref(o, x), "test 21");
|
||||
|
||||
checkequal(22, Overload_byval2forwardref(o, x), "test 22");
|
||||
|
||||
exec("swigtest.quit", -1);
|
||||
|
||||
52
Examples/test-suite/tcl/overload_null_runme.tcl
Normal file
52
Examples/test-suite/tcl/overload_null_runme.tcl
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
|
||||
if [ catch { load ./overload_null[info sharedlibextension] overload_null} err_msg ] {
|
||||
puts stderr "Could not load shared object:\n$err_msg"
|
||||
}
|
||||
|
||||
proc check {what expected actual} {
|
||||
if {$expected != $actual } {
|
||||
error "Failed: $what Expected: $expected , Actual: $actual"
|
||||
}
|
||||
}
|
||||
|
||||
set o [Overload]
|
||||
set x [X]
|
||||
|
||||
check "test1 " 1 [$o byval1 $x]
|
||||
check "test2 " 2 [$o byval1 "NULL"]
|
||||
|
||||
check "testX" 1 [$o byval1 $x]
|
||||
check "testX" 2 [$o byval1 "NULL"]
|
||||
|
||||
check "testX" 3 [$o byval2 "NULL"]
|
||||
check "testX" 4 [$o byval2 $x]
|
||||
|
||||
check "testX" 5 [$o byref1 $x]
|
||||
check "testX" 6 [$o byref1 "NULL"]
|
||||
|
||||
check "testX" 7 [$o byref2 "NULL"]
|
||||
check "testX" 8 [$o byref2 $x]
|
||||
|
||||
check "testX" 9 [$o byconstref1 $x]
|
||||
check "testX" 10 [$o byconstref1 "NULL"]
|
||||
|
||||
check "testX" 11 [$o byconstref2 "NULL"]
|
||||
check "testX" 12 [$o byconstref2 $x]
|
||||
|
||||
# const pointer references
|
||||
check "testX" 13 [$o byval1cpr $x]
|
||||
check "testX" 14 [$o byval1cpr "NULL"]
|
||||
|
||||
check "testX" 15 [$o byval2cpr "NULL"]
|
||||
check "testX" 16 [$o byval2cpr $x]
|
||||
|
||||
# forward class declaration
|
||||
check "testX" 17 [$o byval1forwardptr $x]
|
||||
check "testX" 18 [$o byval1forwardptr "NULL"]
|
||||
|
||||
check "testX" 19 [$o byval2forwardptr "NULL"]
|
||||
check "testX" 20 [$o byval2forwardptr $x]
|
||||
|
||||
check "testX" 21 [$o byval1forwardref $x]
|
||||
|
||||
check "testX" 22 [$o byval2forwardref $x]
|
||||
Loading…
Add table
Add a link
Reference in a new issue