File tree Expand file tree Collapse file tree 2 files changed +26
-37
lines changed Expand file tree Collapse file tree 2 files changed +26
-37
lines changed Original file line number Diff line number Diff line change 88 print ("SKIP" )
99 raise SystemExit
1010
11- print ( machine . mem8 )
11+ import unittest
1212
13- try :
14- machine .mem16 [1 ]
15- except ValueError :
16- print ("ValueError" )
1713
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>" )
2217
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 ]
2721
28- try :
29- machine .mem8 [0 :1 ]
30- except TypeError :
31- print ("TypeError" )
22+ with self .assertRaises (ValueError ):
23+ machine .mem16 [1 ] = 1
3224
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 ]
3728
38- try :
39- machine .mem8 ["hello" ]
40- except TypeError :
41- print ("TypeError" )
29+ with self .assertRaises (TypeError ):
30+ machine .mem8 [0 :1 ]
4231
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