Пример #1
0
	def test_accessor_subset(self):
		from bGrease.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_default_set(self):
		from bGrease.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))
Пример #3
0
	def test_basics(self):
		from bGrease.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)
Пример #4
0
	def test_cast(self):
		from bGrease.component.field import Field
		from bGrease.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))