summary refs log tree commit diff stats
path: root/tests/converter/tconvert.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/converter/tconvert.nim')
-rw-r--r--tests/converter/tconvert.nim44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/converter/tconvert.nim b/tests/converter/tconvert.nim
new file mode 100644
index 000000000..5eee2a92d
--- /dev/null
+++ b/tests/converter/tconvert.nim
@@ -0,0 +1,44 @@
+
+converter FloatConversion64(x: int): float64 = return toFloat(x)
+converter FloatConversion32(x: int): float32 = return toFloat(x)
+converter FloatConversionPlain(x: int): float = return toFloat(x)
+
+const width = 500
+const height = 500
+
+proc ImageSurfaceCreate(w, h: float) = discard
+
+ImageSurfaceCreate(width, height)
+
+type TFoo = object
+
+converter toPtr*(some: var TFoo): ptr TFoo = (addr some)
+
+
+proc zoot(x: ptr TFoo) = discard
+var x: Tfoo
+zoot(x)
+
+# issue #6544
+converter withVar(b: var string): int = ord(b[1])
+
+block:
+  var x = "101"
+  var y: int = x # instantiate withVar
+  doAssert(y == ord('0'))
+
+
+######################
+# bug #3503
+type Foo = object
+  r: float
+
+converter toFoo(r: float): Foo =
+  result.r = r
+
+proc `+=`*(x: var Foo, r: float) =
+  x.r += r
+
+var a: Foo
+a.r += 3.0
+