Esempio n. 1
0
from renlight.sdl.args import register_struct


class MyPoint:
    def __init__(self, x, y, k, m, p):
        self.x = x
        self.y = y
        self.k = k
        self.m = m
        self.p = p


register_struct(
    MyPoint,
    'MyPoint',
    fields=[('x', IntArg), ('y', FloatArg), ('k', Vec2Arg), ('m', Vec3Arg),
            ('p', Vec4Arg)],
    factory=lambda: MyPoint(1, 2.0, Vector2(2.2, 3.3), Vector3(3.3, 5.5, 7.7),
                            Vector4(3.3, 6.6, 8.8, 9.9)))


class StructTests(unittest.TestCase):
    def test_struct(self):
        code = """
a1 = MyPoint()
tmp = 66
a1.x = tmp
p1 = a1.x

tmp = 4.4
a1.y = tmp
Esempio n. 2
0
import unittest
from tdasm import Runtime
from renlight.sdl.shader import Shader
from renlight.sdl.args import FloatArg
from renlight.sdl.args import register_struct
from renlight.sdl.arr import Array, ArrayArg


class SuperPoint:
    def __init__(self, x, y):
        self.x = x
        self.y = y


register_struct(SuperPoint,
                'SuperPoint',
                fields=[('x', FloatArg), ('y', FloatArg)],
                factory=lambda: SuperPoint(1.0, 2.0))


class ArrayTests(unittest.TestCase):
    def test_array(self):

        p = SuperPoint(3.0, 4.0)
        arr = Array(p)
        arr.append(p)
        arr.append(p)
        p = SuperPoint(7.0, 9.0)
        arr.append(p)

        code = """
index = 2
Esempio n. 3
0
import unittest
from tdasm import Runtime
from renlight.vector import Vector2, Vector3, Vector4
from renlight.sdl.shader import Shader
from renlight.sdl.args import IntArg, FloatArg, Vec2Arg, Vec3Arg, Vec4Arg, StructArgPtr
from renlight.sdl.args import register_struct


class TestPoint:
    def __init__(self, x, y):
        self.x = x
        self.y = y


register_struct(TestPoint, "TestPoint", fields=[("x", FloatArg), ("y", FloatArg)], factory=lambda: TestPoint(1.0, 2.0))


class FuncCallTests(unittest.TestCase):
    def setUp(self):
        self.runtimes = [Runtime()]

    def test_call(self):
        code = """
tmp = p1 + p2 + p3
p4.x = 55.99
return tmp
        """
        p1 = FloatArg("p1", 2.0)
        p2 = IntArg("p2", 0)
        p3 = FloatArg("p3", 0.0)
        p4 = StructArgPtr("p4", TestPoint(4.4, 5.5))
Esempio n. 4
0
from renlight.vector import Vector2, Vector3, Vector4
from renlight.sdl.shader import Shader
from renlight.sdl.args import IntArg, FloatArg, Vec2Arg, Vec3Arg, Vec4Arg
from renlight.sdl.args import register_struct


class MyPoint:
    def __init__(self, x, y, k, m, p):
        self.x = x
        self.y = y
        self.k = k
        self.m = m
        self.p = p

register_struct(MyPoint, 'MyPoint', fields=[('x', IntArg),
               ('y', FloatArg), ('k', Vec2Arg), ('m', Vec3Arg),
               ('p', Vec4Arg)], factory=lambda:
               MyPoint(1, 2.0, Vector2(2.2, 3.3), Vector3(3.3, 5.5, 7.7), Vector4(3.3, 6.6, 8.8, 9.9)))


class StructTests(unittest.TestCase):

    def test_struct(self):
        code = """
a1 = MyPoint()
tmp = 66
a1.x = tmp
p1 = a1.x

tmp = 4.4
a1.y = tmp
p2 = a1.y
Esempio n. 5
0
import unittest
from tdasm import Runtime
from renlight.sdl.shader import Shader
from renlight.sdl.args import FloatArg
from renlight.sdl.args import register_struct
from renlight.sdl.arr import Array, ArrayArg


class SuperPoint:
    def __init__(self, x, y):
        self.x = x
        self.y = y


register_struct(
    SuperPoint, "SuperPoint", fields=[("x", FloatArg), ("y", FloatArg)], factory=lambda: SuperPoint(1.0, 2.0)
)


class ArrayTests(unittest.TestCase):
    def test_array(self):

        p = SuperPoint(3.0, 4.0)
        arr = Array(p)
        arr.append(p)
        arr.append(p)
        p = SuperPoint(7.0, 9.0)
        arr.append(p)

        code = """
index = 2
Esempio n. 6
0
import unittest
from tdasm import Runtime
from renlight.vector import Vector2, Vector3, Vector4
from renlight.sdl.shader import Shader
from renlight.sdl.args import IntArg, FloatArg, Vec2Arg, Vec3Arg, Vec4Arg, StructArgPtr
from renlight.sdl.args import register_struct


class TestPoint:
    def __init__(self, x, y):
        self.x = x
        self.y = y

register_struct(TestPoint, 'TestPoint', fields=[('x', FloatArg),
               ('y', FloatArg)], factory=lambda: TestPoint(1.0, 2.0))


class FuncCallTests(unittest.TestCase):

    def setUp(self):
        self.runtimes = [Runtime()]

    def test_call(self):
        code = """
tmp = p1 + p2 + p3
p4.x = 55.99
return tmp
        """
        p1 = FloatArg('p1', 2.0)
        p2 = IntArg('p2', 0)