File size: 586 Bytes
2076ea0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from runtime.runtime import run_source
from runtime.types import Integer, String

def test_const():
    env = run_source('const x = 42')

def test_arithmetic():
    run_source('const r = 2 + 3 * 4')

def test_sha256_hex():
    run_source('''
const h = sha256_hex(hex_to_bytes("616263"))
''')

def test_ledger_example():
    import os
    path = os.path.join(os.path.dirname(__file__), '..', 'examples', 'ledger.m')
    from runtime.runtime import run_file
    run_file(path)

def test_function():
    run_source('''
define double(x)
begin
    return x + x
end
const r = double(21)
''')