[Commit] nickle/test Makefile.am,1.2,1.3 reftest.5c,NONE,1.1

Keith Packard commit at keithp.com
Fri Jul 8 22:46:57 PDT 2005


Committed by: keithp

Update of /local/src/CVS/nickle/test
In directory home.keithp.com:/tmp/cvs-serv10671/test

Modified Files:
	Makefile.am 
Added Files:
	reftest.5c 
Log Message:
2005-07-08  Keith Packard  <keithp at keithp.com>

	* builtin-sockets.c: (do_Socket_connect):
	Set SO_BROADCAST just in case
	
	* compile.c: (CompileCall):
	CompileCall with auto_reference == True must not
	return a pointer to the return type as this function
	is called from CompileLvalue which is defined to return
	the type of the underlying object, not a pointer to
	that type. The alternative is to return a reference type,
	and I'm fairly sure that's not right as & is supposed
	to return a pointer type, not a reference type, right?
	
	* nickle.spec.in:
	Make sure the nickle headers are installed
	
	* test/Makefile.am:
	* test/reftest.5c:
	Add a test for reference types which checks the above
	change


Index: Makefile.am
===================================================================
RCS file: /local/src/CVS/nickle/test/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Makefile.am	16 Feb 2004 00:15:05 -0000	1.2
+++ Makefile.am	9 Jul 2005 05:46:54 -0000	1.3
@@ -2,7 +2,8 @@
 	inttest.5c \
 	optest.5c \
 	orderofoptest.5c \
-	rattest.5c
+	rattest.5c \
+	reftest.5c
 TESTS_ENVIRONMENT=NICKLESTART=$(top_srcdir)/builtin.5c NICKLEPATH=$(top_srcdir) ../nickle
 TESTS=$(check_SCRIPTS)
 

--- NEW FILE: reftest.5c ---
/*
 * Test various pointer and reference type combinations
 */

exception bad_result (poly a, poly b);

int i = 7;
string s = "hi";

&int ir = &i;

i = 8;

/* make sure references see changes to the underlying object */
if (i != ir)
    raise bad_result (i, ir);

*int ip = &i;

i = 9;

/* make sure pointers see changes to the underlying object */
if (i != *ip)
    raise bad_result (i, *ip);

if (ir != *ip)
    raise bad_result (ir, *ip);

/*
 * Make sure function return values typecheck correctly
 */
typedef s;
typedef struct {
    &s x;
} s;


s u() {
    s v;

    &v.x = reference(u());
    return v;
}

s t() {
    s v;

    &v.x = &t();
    return v;
}




More information about the Commit mailing list