new tester; all tests categorized
This commit is contained in:
parent
51ee524109
commit
20b5f31c03
481 changed files with 794 additions and 2506 deletions
5
tests/converter/tconvcolors.nim
Normal file
5
tests/converter/tconvcolors.nim
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
import colors
|
||||
|
||||
echo int32(colWhite), 'A'
|
||||
|
||||
46
tests/converter/tconvert.nim
Normal file
46
tests/converter/tconvert.nim
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import
|
||||
Cairo
|
||||
|
||||
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
|
||||
const outFile = "CairoTest.png"
|
||||
|
||||
var surface = Cairo.ImageSurfaceCreate(CAIRO.FORMAT_RGB24, width, height)
|
||||
var ç = Cairo.Create(surface)
|
||||
|
||||
ç.SetSourceRGB(1, 1, 1)
|
||||
ç.Paint()
|
||||
|
||||
ç.SetLineWidth(10)
|
||||
ç.SetLineCap(CAIRO.LINE_CAP_ROUND)
|
||||
|
||||
const count = 12
|
||||
var winc = width / count
|
||||
var hinc = width / count
|
||||
for i in 1 .. count-1:
|
||||
var amount = i / count
|
||||
ç.SetSourceRGB(0, 1 - amount, amount)
|
||||
ç.MoveTo(i * winc, hinc)
|
||||
ç.LineTo(width - i * winc, height - hinc)
|
||||
ç.Stroke()
|
||||
|
||||
ç.SetSourceRGB(1 - amount, 0, amount)
|
||||
ç.MoveTo(winc, i * hinc)
|
||||
ç.LineTo(width - winc, height - i * hinc)
|
||||
ç.Stroke()
|
||||
|
||||
echo(surface.WriteToPNG(outFile))
|
||||
surface.Destroy()
|
||||
|
||||
type TFoo = object
|
||||
|
||||
converter toPtr*(some: var TFoo): ptr TFoo = (addr some)
|
||||
|
||||
|
||||
proc zoot(x: ptr TFoo) = nil
|
||||
var x: Tfoo
|
||||
zoot(x)
|
||||
30
tests/converter/tgenericconverter.nim
Normal file
30
tests/converter/tgenericconverter.nim
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
discard """
|
||||
output: '''666
|
||||
666'''
|
||||
"""
|
||||
|
||||
# test the new generic converters:
|
||||
|
||||
type
|
||||
TFoo2[T] = object
|
||||
x: T
|
||||
|
||||
TFoo[T] = object
|
||||
data: array[0..100, T]
|
||||
|
||||
converter toFoo[T](a: TFoo2[T]): TFoo[T] =
|
||||
result.data[0] = a.x
|
||||
|
||||
proc p(a: TFoo[int]) =
|
||||
echo a.data[0]
|
||||
|
||||
proc q[T](a: TFoo[T]) =
|
||||
echo a.data[0]
|
||||
|
||||
|
||||
var
|
||||
aa: TFoo2[int]
|
||||
aa.x = 666
|
||||
|
||||
p aa
|
||||
q aa
|
||||
8
tests/converter/ttypeconverter1.nim
Normal file
8
tests/converter/ttypeconverter1.nim
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
converter p(i: int): bool = return i != 0
|
||||
|
||||
if 1:
|
||||
echo if 4: "foo" else: "barr"
|
||||
while 0:
|
||||
echo "bar"
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue