コード例 #1
0
ファイル: field_test.py プロジェクト: caseman/grease
	def test_accessor_subset(self):
		from grease.component.field import Field
		comp = TestComponent((1,2,3,4))
		f = Field(comp, "acc_default", str, TestAccessor)
		acc = f.accessor(set([2,4,6,8]))
		self.assertTrue(acc.field is f, (acc.field, f))
		self.assertEqual(acc.entities, set([2,4]))
コード例 #2
0
 def test_accessor_subset(self):
     from grease.component.field import Field
     comp = TestComponent((1, 2, 3, 4))
     f = Field(comp, "acc_default", str, TestAccessor)
     acc = f.accessor(set([2, 4, 6, 8]))
     self.assertTrue(acc.field is f, (acc.field, f))
     self.assertEqual(acc.entities, set([2, 4]))
コード例 #3
0
ファイル: field_test.py プロジェクト: caseman/grease
	def test_accessor_default_set(self):
		from grease.component.field import Field
		comp = TestComponent()
		f = Field(comp, "acc_default", str, TestAccessor)
		acc = f.accessor()
		self.assertTrue(acc.field is f, (acc.field, f))
		self.assertTrue(acc.entities is comp.entities, (acc.entities, comp.entities))
コード例 #4
0
ファイル: field_test.py プロジェクト: caseman/grease
	def test_basics(self):
		from grease.component.field import Field
		comp = TestComponent()

		f = Field(comp, "myfield", int)
		self.assertTrue(f.component is comp, (f.component, comp))
		self.assertTrue(f.type is int, f.type)
		self.assertEqual(f.default(), 0)
コード例 #5
0
 def test_accessor_default_set(self):
     from grease.component.field import Field
     comp = TestComponent()
     f = Field(comp, "acc_default", str, TestAccessor)
     acc = f.accessor()
     self.assertTrue(acc.field is f, (acc.field, f))
     self.assertTrue(acc.entities is comp.entities,
                     (acc.entities, comp.entities))
コード例 #6
0
    def test_basics(self):
        from grease.component.field import Field
        comp = TestComponent()

        f = Field(comp, "myfield", int)
        self.assertTrue(f.component is comp, (f.component, comp))
        self.assertTrue(f.type is int, f.type)
        self.assertEqual(f.default(), 0)
コード例 #7
0
 def test_cast(self):
     from grease.component.field import Field
     from grease.geometry import Vec2d
     f = Field(None, "string", str)
     self.assertEqual(f.cast(22), "22")
     f = Field(None, "int", int)
     self.assertEqual(f.cast("42"), 42)
     f = Field(None, "vec", Vec2d)
     self.assertEqual(f.cast((11, 12)), Vec2d(11, 12))
コード例 #8
0
ファイル: field_test.py プロジェクト: caseman/grease
	def test_cast(self):
		from grease.component.field import Field
		from grease.geometry import Vec2d
		f = Field(None, "string", str)
		self.assertEqual(f.cast(22), "22")
		f = Field(None, "int", int)
		self.assertEqual(f.cast("42"), 42)
		f = Field(None, "vec", Vec2d)
		self.assertEqual(f.cast((11,12)), Vec2d(11,12))