~james/gengo

gengo/samples-test/samples/Python/minecraft.py -rw-r--r-- 738 bytes
50871857 — james chore(import): snapshot james.dad.town/gengo at 8f775550b0ee 16 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from uuid import uuid4
from unittest import TestCase

class Item:
    def __init__(self):
        self.id = uuid4()

class Charcoal(Item):
    pass

class Stick(Item):
    def __add__(self, other):
        return Torch(self, other)

class Torch(Item):
    def __init__(self, stick: Stick, charcoal: Charcoal):
        super().__init__()
        self.stick = stick
        self.charcoal = charcoal

    def components(self):
        return [self.stick, self.charcoal]

class TestMinecraft(TestCase):
    def test_torch(self):
        stick = Stick()
        charcoal = Charcoal()
        torch = stick + charcoal
        components = torch.components()

        self.assertIn(charcoal, components)
        self.assertIn(stick, components)