38 lines
857 B
Text
38 lines
857 B
Text
$NetBSD: patch-be,v 1.2 2005/03/11 23:24:14 is Exp $
|
|
|
|
--- vsuite/quick/ptrstr/pointer.sr.orig 2005-03-11 09:46:25.000000000 +0100
|
|
+++ vsuite/quick/ptrstr/pointer.sr
|
|
@@ -0,0 +1,33 @@
|
|
+resource pointer()
|
|
+ type pt = ptr int
|
|
+ var foo: pt
|
|
+ var bar: pt
|
|
+ var baz: pt
|
|
+ var nul: pt
|
|
+ var foos: string[20]
|
|
+ var bars: string[20]
|
|
+
|
|
+ write("Testing pointer-string-pointer conversions:")
|
|
+
|
|
+ nul := null
|
|
+ write("Null pointer:", nul, "; string:", string(nul),
|
|
+ "; int:", int(nul), "; pt(==null==):", pt("==null=="))
|
|
+
|
|
+ baz := new(int)
|
|
+
|
|
+ foo := new(int)
|
|
+ foos:= string(foo)
|
|
+
|
|
+ bar := pt(foos)
|
|
+ bars:= string(bar)
|
|
+
|
|
+ baz := pt(foos||"X")
|
|
+
|
|
+ write("pointer identity:", foo = bar)
|
|
+ write("string identity:", foos = bars)
|
|
+ write("pointerX identity:", foo = baz)
|
|
+
|
|
+ write("Expect invalid conversion:")
|
|
+ baz := pt("invalid")
|
|
+
|
|
+end
|