Exemple #1
0
    def test_mult(self):
        """should print the number 72 to the console"""
        cpu = CPU()

        program_file = './ls8/examples/mult.ls8'
        cpu.load(program_file)
        cpu.run()
        result = self.capturedOutput.getvalue().strip()
        self.assertEqual(result, '72', f'Expected 72 but got {result}')
Exemple #2
0
    def test_print8(self):
        """should print the number 8 to the console"""
        cpu = CPU()

        program_file = './ls8/examples/print8.ls8'
        cpu.load(program_file)
        cpu.run()
        result = self.capturedOutput.getvalue().strip()
        self.assertEqual(result, '8')
Exemple #3
0
    def test_subroutines(self):
        """should print the numbers 20,30,36,60  to the console"""
        cpu = CPU()

        program_file = './ls8/examples/call.ls8'
        cpu.load(program_file)
        cpu.run()
        expected = '20\n30\n36\n60'
        result = self.capturedOutput.getvalue().strip()
        self.assertEqual(result, expected,
                         f'Expected {expected} but got {result}')
Exemple #4
0
    def test_stack(self):
        """should print the numbers 2,4,1  to the console"""
        cpu = CPU()

        program_file = './ls8/examples/stack.ls8'
        cpu.load(program_file)
        cpu.run()
        expected = '2\n4\n1'
        result = self.capturedOutput.getvalue().strip()
        self.assertEqual(result, expected,
                         f'Expected {expected} but got {result}')
Exemple #5
0
        except Exception as err:
            print(f'Other error occurred: {err}')
        # if the req is good start a timer
        starttime = time.time()
        # make the data JSON
        r = response.json()
        # grab the wait time
        cooldown = r['cooldown']
        print(r["messages"], '\n', r['errors'])
        with open('well_message.txt', 'w') as f:
            f.write(r["description"])

        # load up the LS8 with the well message
        cpu.load("well_message.txt")
        # run the LS8 and decode the message
        cpu.run()
    elif current_action == "get_proof/":
        try:
            response = requests.get(
                'https://lambda-treasure-hunt.herokuapp.com/api/bc/last_proof/',
                headers=SET_HEADERS,
                json=current_data)
            response.raise_for_status()
        except HTTPError as http_err:
            print(f'HTTP error occurred: {http_err}')
        except Exception as err:
            print(f'Other error occurred: {err}')
        # if the req is good start a timer
        starttime = time.time()
        # make the data JSON
        r = response.json()
Exemple #6
0
            print(f'Other error occurred: {err}')
        # if the req is good start a timer
        starttime = time.time()
        # make the data JSON
        r = response.json()
        # grab the wait time
        cooldown = r['cooldown']
        print(r["messages"], '\n', r['errors'])
        # print(r['description'])

        # with open('well_message.txt', 'w') as f:
        #     f.write(r["description"])
        if current_data['name'] == "well":
            cpu = CPU()
            cpu.load(r["description"])
            save = cpu.run()
            cpu = None
            # print("SAVE",save)
            if int(save) < 500:
                cmds.extend([f'f {save}', 'pr', 'm'])
            else:
                cmds.extend([f'f {save}', 'f 555', 'ex well'])
        else:
            print(r['description'])

    elif current_action == "get_proof/":
        # real_proof=0
        # while True:
        time.sleep(cooldown - ((time.time() - starttime) % cooldown))
        try:
            response = requests.get(