コード例 #1
0
 def test_node_output(self):
     floor_node = FloorNode()
     d_node = DataSourceNode(1.2)
     BaseNode.connect(d_node, floor_node, 'data', 'value')
     self.assertEqual(floor_node.resolve_output('result'), 1)
     d_node.data = 1.8
     self.assertEqual(floor_node.resolve_output('result'), 1)
     d_node.data = -4.4
     self.assertEqual(floor_node.resolve_output('result'), -5)
コード例 #2
0
 def test_node_output(self):
     ceil_node = CeilNode()
     d_node = DataSourceNode(1.2)
     BaseNode.connect(d_node, ceil_node, 'data', 'value')
     self.assertEqual(ceil_node.resolve_output('result'), 2)
     d_node.data = 1.8
     self.assertEqual(ceil_node.resolve_output('result'), 2)
     d_node.data = -4.4
     self.assertEqual(ceil_node.resolve_output('result'), -4)
コード例 #3
0
 def test_node_output(self):
     abs_node = AbsoluteValueNode()
     d_node = DataSourceNode(6.5)
     BaseNode.connect(d_node, abs_node, 'data', 'in')
     self.assertEqual(abs_node.resolve_output('result'), 6.5)
     d_node.data = -4.2
     self.assertEqual(abs_node.resolve_output('result'), 4.2)
     d_node.data = 0.
     self.assertEqual(abs_node.resolve_output('result'), 0)
コード例 #4
0
 def test_and_false(self):
     and_node = AndNode()
     d1 = DataSourceNode(True)
     d2 = DataSourceNode(False)
     BaseNode.connect(d1, and_node, 'data', 'arg1')
     BaseNode.connect(d2, and_node, 'data', 'arg2')
     self.assertFalse(and_node.resolve_output('result'))
     d1.data = False
     self.assertFalse(and_node.resolve_output('result'))
     d2.data = True
     self.assertFalse(and_node.resolve_output('result'))
コード例 #5
0
 def test_node_output(self):
     round_node = RoundNode()
     d_node = DataSourceNode(1.2)
     BaseNode.connect(d_node, round_node, 'data', 'value')
     self.assertEqual(round_node.resolve_output('result'), 1)
     d_node.data = 1.8
     self.assertEqual(round_node.resolve_output('result'), 2)
     d_node.data = -4.4
     self.assertEqual(round_node.resolve_output('result'), -4)
     d_node.data = 4.5
     self.assertEqual(round_node.resolve_output('result'), 5)
コード例 #6
0
 def test_or_true(self):
     or_node = OrNode()
     d1 = DataSourceNode(True)
     d2 = DataSourceNode(True)
     BaseNode.connect(d1, or_node, 'data', 'arg1')
     BaseNode.connect(d2, or_node, 'data', 'arg2')
     self.assertTrue(or_node.resolve_output('result'))
     d1.data = False
     self.assertTrue(or_node.resolve_output('result'))
     d1.data = True
     d2.data = False
     self.assertTrue(or_node.resolve_output('result'))