File tree 2 files changed +26
-37
lines changed 2 files changed +26
-37
lines changed Original file line number Diff line number Diff line change 8
8
print ("SKIP" )
9
9
raise SystemExit
10
10
11
- print ( machine . mem8 )
11
+ import unittest
12
12
13
- try :
14
- machine .mem16 [1 ]
15
- except ValueError :
16
- print ("ValueError" )
17
13
18
- try :
19
- machine .mem16 [1 ] = 1
20
- except ValueError :
21
- print ("ValueError" )
14
+ class Test (unittest .TestCase ):
15
+ def test_mem8_print (self ):
16
+ self .assertEqual (repr (machine .mem8 ), "<8-bit memory>" )
22
17
23
- try :
24
- del machine .mem8 [0 ]
25
- except TypeError :
26
- print ("TypeError" )
18
+ def test_alignment (self ):
19
+ with self .assertRaises (ValueError ):
20
+ machine .mem16 [1 ]
27
21
28
- try :
29
- machine .mem8 [0 :1 ]
30
- except TypeError :
31
- print ("TypeError" )
22
+ with self .assertRaises (ValueError ):
23
+ machine .mem16 [1 ] = 1
32
24
33
- try :
34
- machine .mem8 [0 :1 ] = 10
35
- except TypeError :
36
- print ("TypeError" )
25
+ def test_operations (self ):
26
+ with self .assertRaises (TypeError ):
27
+ del machine .mem8 [0 ]
37
28
38
- try :
39
- machine .mem8 ["hello" ]
40
- except TypeError :
41
- print ("TypeError" )
29
+ with self .assertRaises (TypeError ):
30
+ machine .mem8 [0 :1 ]
42
31
43
- try :
44
- machine .mem8 ["hello" ] = 10
45
- except TypeError :
46
- print ("TypeError" )
32
+ with self .assertRaises (TypeError ):
33
+ machine .mem8 [0 :1 ] = 10
34
+
35
+ with self .assertRaises (TypeError ):
36
+ machine .mem8 ["hello" ]
37
+
38
+ with self .assertRaises (TypeError ):
39
+ machine .mem8 ["hello" ] = 10
40
+
41
+
42
+ if __name__ == "__main__" :
43
+ unittest .main ()
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments