Skip to content

Commit 69f4022

Browse files
committed
Add definitions feature
1 parent e3e04b6 commit 69f4022

23 files changed

+572
-193
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ ca65 V2.18 - Ubuntu 2.19-1
153153
- [Customize configurations](https://github.com/AsaiYusuke/6502_test_executor/blob/master/example/test/ok/customize.configurations.test.json)
154154
- [Skip test (ignore)](https://github.com/AsaiYusuke/6502_test_executor/blob/master/example/test/ok/skip.test.json)
155155
- [Complex evaluation](https://github.com/AsaiYusuke/6502_test_executor/blob/master/example/test/ok/evaluation.test.json)
156+
- [Definitions](https://github.com/AsaiYusuke/6502_test_executor/blob/master/example/test/ok/definitions.test.json)
156157

157158
# Dependencies
158159
This project uses following project:

example/test/ok/definitions.test.json

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
{
2+
"$schema": "../../../schema/testcase.schema.json",
3+
"target": {
4+
"start": {
5+
"label": "control"
6+
}
7+
},
8+
"definitions": {
9+
"setup": {
10+
"registerAXY": {
11+
"INITIAL_AXY": 100
12+
},
13+
"registerP": {
14+
"SETUP_ALL_FALSE": {
15+
"Carry": false,
16+
"Decimal": false,
17+
"InterruptDisable": false,
18+
"Negative": false,
19+
"Overflow": false,
20+
"Zero": false
21+
},
22+
"SET_CARRY_TRUE": {
23+
"Carry": true
24+
},
25+
"SET_CARRY_FALSE": {
26+
"Carry": false
27+
}
28+
},
29+
"memory": {
30+
"value": {
31+
"INITIAL_VECTOR": 0
32+
},
33+
"sequence": {
34+
"PAD1_INPUT_A_OFF_ON_OFF": [
35+
0,
36+
1,
37+
0
38+
]
39+
}
40+
}
41+
},
42+
"expected": {
43+
"registerAXY": {
44+
"STAY_INITIAL": {
45+
"eq": 100
46+
},
47+
"SUCCESSFULLY_ADDED": {
48+
"eq": 4
49+
}
50+
},
51+
"registerP": {
52+
"EXPECTED_ALL_FALSE_EXCEPT_N": {
53+
"Carry": {
54+
"eq": false
55+
},
56+
"Decimal": {
57+
"eq": false
58+
},
59+
"InterruptDisable": {
60+
"eq": false
61+
},
62+
"Negative": {
63+
"eq": true
64+
},
65+
"Overflow": {
66+
"eq": false
67+
},
68+
"Zero": {
69+
"eq": false
70+
}
71+
}
72+
},
73+
"memory": {
74+
"value": {
75+
"UPDATED_VECTOR_IS_4": [
76+
{
77+
"eq": 4
78+
}
79+
]
80+
},
81+
"count": {
82+
"NMI_LOCK_EXECUTED": {
83+
"gt": 0
84+
}
85+
}
86+
}
87+
}
88+
},
89+
"cases": {
90+
"NMI interrupt (definitions)": {
91+
"setup": {
92+
"memory": [
93+
{
94+
"label": "vector_addr",
95+
"value": "@INITIAL_VECTOR"
96+
},
97+
{
98+
"label": "APU_PAD1",
99+
"sequence": "@PAD1_INPUT_A_OFF_ON_OFF"
100+
}
101+
],
102+
"interrupt": [
103+
{
104+
"type": "NMI",
105+
"entryPoint": {
106+
"label": "save_id"
107+
}
108+
}
109+
]
110+
111+
},
112+
"expected": {
113+
"memory": [
114+
{
115+
"label": "vector_addr",
116+
"value": "@UPDATED_VECTOR_IS_4"
117+
},
118+
{
119+
"label": "nmi_lock",
120+
"readCount": "@NMI_LOCK_EXECUTED"
121+
}
122+
]
123+
}
124+
},
125+
"call mocked proc read_joypad_a_key (definitions)": {
126+
"setup": {
127+
"register": {
128+
"P": "@SETUP_ALL_FALSE"
129+
},
130+
"mockedProc": [
131+
{
132+
"entryPoint": {
133+
"label": "read_joypad_a_key"
134+
},
135+
"action": "rts",
136+
"setValue": [
137+
{
138+
"register": {
139+
"P": "@SET_CARRY_TRUE"
140+
}
141+
},
142+
{
143+
"register": {
144+
"P": "@SET_CARRY_FALSE"
145+
}
146+
}
147+
148+
]
149+
}
150+
]
151+
},
152+
"expected": {
153+
"timeout": {
154+
"eq": false
155+
},
156+
"register": {
157+
"P": "@EXPECTED_ALL_FALSE_EXCEPT_N"
158+
}
159+
}
160+
},
161+
"accessed only A": {
162+
"setup": {
163+
"register": {
164+
"A": "@INITIAL_AXY",
165+
"X": "@INITIAL_AXY",
166+
"Y": "@INITIAL_AXY"
167+
},
168+
"memory": [
169+
{
170+
"label": "vector_addr",
171+
"value": "@INITIAL_VECTOR"
172+
},
173+
{
174+
"label": "APU_PAD1",
175+
"sequence": "@PAD1_INPUT_A_OFF_ON_OFF"
176+
}
177+
]
178+
},
179+
"expected": {
180+
"register": {
181+
"A": "@SUCCESSFULLY_ADDED",
182+
"X": "@STAY_INITIAL",
183+
"Y": "@STAY_INITIAL"
184+
}
185+
}
186+
}
187+
}
188+
}

example/test/ok/mock.proc.test.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@
2727
"P": {
2828
"Carry": false
2929
}
30-
},
31-
"memory": {
32-
"label": "test",
33-
"value": {
34-
"type": "value",
35-
"label": "test"
36-
}
3730
}
3831
}
3932
]

include/condition/condition.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ class condition
4141
condition_timeout *get_timeout_def();
4242

4343
public:
44-
condition(emulation_devices *_device, json condition_json, json target);
45-
condition(emulation_devices *_device, json condition_json);
44+
condition(emulation_devices *_device, json definitions_def, json condition_json, json target);
45+
condition(emulation_devices *_device, json definitions_def, json condition_json);
4646
};

include/condition/condition_memory.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ class condition_memory
1818
vector<condition_memory_count> write_counts;
1919

2020
string create_address_name(emulation_devices *device, json memory_def, int offset);
21-
json normalize_value_sequences(emulation_devices *device, json memory_def);
22-
json normalize_read_counts(emulation_devices *device, json memory_def);
23-
json normalize_write_counts(emulation_devices *device, json memory_def);
21+
json normalize_value_sequences(emulation_devices *device, json definitions_def, json memory_def);
22+
json normalize_read_counts(emulation_devices *device, json definitions_def, json memory_def);
23+
json normalize_write_counts(emulation_devices *device, json definitions_def, json memory_def);
2424

2525
public:
26-
condition_memory(emulation_devices *device, json condition);
26+
condition_memory(emulation_devices *device, json definitions_def, json condition);
2727
vector<condition_memory_value> get_value_sequences();
2828
vector<condition_memory_count> get_read_counts();
2929
vector<condition_memory_count> get_write_counts();

include/condition/condition_mocked_proc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class condition_mocked_proc
1919
vector<condition_mocked_value> mock_value_defs;
2020

2121
public:
22-
condition_mocked_proc(emulation_devices *device, json condition);
22+
condition_mocked_proc(emulation_devices *device, json definitions_def, json condition);
2323
uint16_t get_entry_point();
2424
mock_action_type get_action();
2525
uint16_t get_jmp_dest();

include/condition/condition_mocked_value.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class emulation_devices;
1212
class condition_mocked_value : condition
1313
{
1414
public:
15-
condition_mocked_value(emulation_devices *device, json condition_json);
15+
condition_mocked_value(emulation_devices *device, json definitions_def, json condition_json);
1616
vector<condition_register_a_x_y> get_register_defs();
1717
vector<condition_register_status_flag> get_status_flag_defs();
1818
vector<condition_memory> get_memory_defs();

include/exception/cpu_runtime_error.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class cpu_runtime_error : public runtime_error
1414

1515
public:
1616
cpu_runtime_error(runtime_error_type _type, string message)
17-
: runtime_error(message) {
17+
: runtime_error(message)
18+
{
1819
type = _type;
1920
}
2021

include/exception/parse_abort.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ class parse_abort
77
private:
88
int return_value;
99
public:
10-
parse_abort(int _return_value) {
10+
parse_abort(int _return_value)
11+
{
1112
return_value = _return_value;
1213
}
1314

include/exception/parse_ignore_entry.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ using namespace std;
55
class parse_ignore_entry
66
{
77
public:
8-
parse_ignore_entry() {
8+
parse_ignore_entry()
9+
{
910
}
1011
};

0 commit comments

Comments
 (0)