procedures.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. <xml xmlns="http://www.w3.org/1999/xhtml">
  2. <block type="unittest_main" x="0" y="1">
  3. <statement name="DO">
  4. <block type="procedures_callnoreturn">
  5. <mutation name="test procedure"></mutation>
  6. <next>
  7. <block type="procedures_callnoreturn">
  8. <mutation name="test function"></mutation>
  9. <next>
  10. <block type="unittest_assertequals" inline="false">
  11. <field name="MESSAGE">test recurse</field>
  12. <value name="ACTUAL">
  13. <block type="procedures_callreturn" inline="false">
  14. <mutation name="recurse">
  15. <arg name="n"></arg>
  16. </mutation>
  17. <value name="ARG0">
  18. <block type="math_number">
  19. <field name="NUM">3</field>
  20. </block>
  21. </value>
  22. </block>
  23. </value>
  24. <value name="EXPECTED">
  25. <block type="text">
  26. <field name="TEXT">-1-2-1-3-1-2-1-</field>
  27. </block>
  28. </value>
  29. </block>
  30. </next>
  31. </block>
  32. </next>
  33. </block>
  34. </statement>
  35. </block>
  36. <block type="procedures_defnoreturn" x="-3" y="249">
  37. <mutation></mutation>
  38. <field name="NAME">test procedure</field>
  39. <statement name="STACK">
  40. <block type="procedures_callnoreturn" inline="false">
  41. <mutation name="procedure 1">
  42. <arg name="proc x"></arg>
  43. <arg name="proc y"></arg>
  44. </mutation>
  45. <value name="ARG0">
  46. <block type="math_number">
  47. <field name="NUM">8</field>
  48. </block>
  49. </value>
  50. <value name="ARG1">
  51. <block type="math_number">
  52. <field name="NUM">2</field>
  53. </block>
  54. </value>
  55. <next>
  56. <block type="unittest_assertequals" inline="false">
  57. <field name="MESSAGE">procedure with global</field>
  58. <value name="ACTUAL">
  59. <block type="variables_get">
  60. <field name="VAR">proc z</field>
  61. </block>
  62. </value>
  63. <value name="EXPECTED">
  64. <block type="math_number">
  65. <field name="NUM">4</field>
  66. </block>
  67. </value>
  68. <next>
  69. <block type="variables_set" inline="false">
  70. <field name="VAR">proc w</field>
  71. <value name="VALUE">
  72. <block type="logic_boolean">
  73. <field name="BOOL">FALSE</field>
  74. </block>
  75. </value>
  76. <next>
  77. <block type="procedures_callnoreturn" inline="false">
  78. <mutation name="procedure 2">
  79. <arg name="proc x"></arg>
  80. </mutation>
  81. <value name="ARG0">
  82. <block type="logic_boolean">
  83. <field name="BOOL">FALSE</field>
  84. </block>
  85. </value>
  86. <next>
  87. <block type="unittest_assertvalue" inline="false">
  88. <field name="MESSAGE">procedure no return</field>
  89. <field name="EXPECTED">TRUE</field>
  90. <value name="ACTUAL">
  91. <block type="variables_get">
  92. <field name="VAR">proc w</field>
  93. </block>
  94. </value>
  95. <next>
  96. <block type="variables_set" inline="false">
  97. <field name="VAR">proc w</field>
  98. <value name="VALUE">
  99. <block type="logic_boolean">
  100. <field name="BOOL">FALSE</field>
  101. </block>
  102. </value>
  103. <next>
  104. <block type="procedures_callnoreturn" inline="false">
  105. <mutation name="procedure 2">
  106. <arg name="proc x"></arg>
  107. </mutation>
  108. <value name="ARG0">
  109. <block type="logic_boolean">
  110. <field name="BOOL">TRUE</field>
  111. </block>
  112. </value>
  113. <next>
  114. <block type="unittest_assertvalue" inline="false">
  115. <field name="MESSAGE">procedure return</field>
  116. <field name="EXPECTED">FALSE</field>
  117. <value name="ACTUAL">
  118. <block type="variables_get">
  119. <field name="VAR">proc w</field>
  120. </block>
  121. </value>
  122. </block>
  123. </next>
  124. </block>
  125. </next>
  126. </block>
  127. </next>
  128. </block>
  129. </next>
  130. </block>
  131. </next>
  132. </block>
  133. </next>
  134. </block>
  135. </next>
  136. </block>
  137. </statement>
  138. </block>
  139. <block type="procedures_defnoreturn" x="302" y="277">
  140. <mutation>
  141. <arg name="proc x"></arg>
  142. <arg name="proc y"></arg>
  143. </mutation>
  144. <field name="NAME">procedure 1</field>
  145. <statement name="STACK">
  146. <block type="variables_set" inline="false">
  147. <field name="VAR">proc z</field>
  148. <value name="VALUE">
  149. <block type="math_arithmetic" inline="true">
  150. <field name="OP">DIVIDE</field>
  151. <value name="A">
  152. <block type="variables_get">
  153. <field name="VAR">proc x</field>
  154. </block>
  155. </value>
  156. <value name="B">
  157. <block type="variables_get">
  158. <field name="VAR">proc y</field>
  159. </block>
  160. </value>
  161. </block>
  162. </value>
  163. </block>
  164. </statement>
  165. </block>
  166. <block type="procedures_defnoreturn" x="307" y="435">
  167. <mutation>
  168. <arg name="proc x"></arg>
  169. </mutation>
  170. <field name="NAME">procedure 2</field>
  171. <statement name="STACK">
  172. <block type="procedures_ifreturn" inline="true">
  173. <mutation value="0"></mutation>
  174. <value name="CONDITION">
  175. <block type="variables_get">
  176. <field name="VAR">proc x</field>
  177. </block>
  178. </value>
  179. <next>
  180. <block type="variables_set" inline="false">
  181. <field name="VAR">proc w</field>
  182. <value name="VALUE">
  183. <block type="logic_boolean">
  184. <field name="BOOL">TRUE</field>
  185. </block>
  186. </value>
  187. </block>
  188. </next>
  189. </block>
  190. </statement>
  191. </block>
  192. <block type="procedures_defnoreturn" x="-2" y="731">
  193. <mutation></mutation>
  194. <field name="NAME">test function</field>
  195. <statement name="STACK">
  196. <block type="unittest_assertequals" inline="false">
  197. <field name="MESSAGE">function with arguments</field>
  198. <value name="ACTUAL">
  199. <block type="procedures_callreturn" inline="false">
  200. <mutation name="function 1">
  201. <arg name="func x"></arg>
  202. <arg name="func y"></arg>
  203. </mutation>
  204. <value name="ARG0">
  205. <block type="math_number">
  206. <field name="NUM">2</field>
  207. </block>
  208. </value>
  209. <value name="ARG1">
  210. <block type="math_number">
  211. <field name="NUM">3</field>
  212. </block>
  213. </value>
  214. </block>
  215. </value>
  216. <value name="EXPECTED">
  217. <block type="math_number">
  218. <field name="NUM">-1</field>
  219. </block>
  220. </value>
  221. <next>
  222. <block type="unittest_assertequals" inline="false">
  223. <field name="MESSAGE">function with side effect</field>
  224. <value name="ACTUAL">
  225. <block type="variables_get">
  226. <field name="VAR">func z</field>
  227. </block>
  228. </value>
  229. <value name="EXPECTED">
  230. <block type="text">
  231. <field name="TEXT">side effect</field>
  232. </block>
  233. </value>
  234. <next>
  235. <block type="variables_set" inline="false">
  236. <field name="VAR">func a</field>
  237. <value name="VALUE">
  238. <block type="text">
  239. <field name="TEXT">unchanged</field>
  240. </block>
  241. </value>
  242. <next>
  243. <block type="variables_set" inline="false">
  244. <field name="VAR">func c</field>
  245. <value name="VALUE">
  246. <block type="text">
  247. <field name="TEXT">global</field>
  248. </block>
  249. </value>
  250. <next>
  251. <block type="unittest_assertequals" inline="false">
  252. <field name="MESSAGE">function with global</field>
  253. <value name="ACTUAL">
  254. <block type="procedures_callreturn" inline="false">
  255. <mutation name="function 2">
  256. <arg name="func a"></arg>
  257. </mutation>
  258. <value name="ARG0">
  259. <block type="math_number">
  260. <field name="NUM">2</field>
  261. </block>
  262. </value>
  263. </block>
  264. </value>
  265. <value name="EXPECTED">
  266. <block type="text">
  267. <field name="TEXT">3global</field>
  268. </block>
  269. </value>
  270. <next>
  271. <block type="unittest_assertequals" inline="false">
  272. <field name="MESSAGE">function with scope</field>
  273. <value name="ACTUAL">
  274. <block type="variables_get">
  275. <field name="VAR">func a</field>
  276. </block>
  277. </value>
  278. <value name="EXPECTED">
  279. <block type="text">
  280. <field name="TEXT">unchanged</field>
  281. </block>
  282. </value>
  283. <next>
  284. <block type="unittest_assertvalue" inline="false">
  285. <field name="MESSAGE">function return</field>
  286. <field name="EXPECTED">TRUE</field>
  287. <value name="ACTUAL">
  288. <block type="procedures_callreturn" inline="false">
  289. <mutation name="function 3">
  290. <arg name="func a"></arg>
  291. </mutation>
  292. <value name="ARG0">
  293. <block type="logic_boolean">
  294. <field name="BOOL">TRUE</field>
  295. </block>
  296. </value>
  297. </block>
  298. </value>
  299. <next>
  300. <block type="unittest_assertvalue" inline="false">
  301. <field name="MESSAGE">function no return</field>
  302. <field name="EXPECTED">FALSE</field>
  303. <value name="ACTUAL">
  304. <block type="procedures_callreturn" inline="false">
  305. <mutation name="function 3">
  306. <arg name="func a"></arg>
  307. </mutation>
  308. <value name="ARG0">
  309. <block type="logic_boolean">
  310. <field name="BOOL">FALSE</field>
  311. </block>
  312. </value>
  313. </block>
  314. </value>
  315. </block>
  316. </next>
  317. </block>
  318. </next>
  319. </block>
  320. </next>
  321. </block>
  322. </next>
  323. </block>
  324. </next>
  325. </block>
  326. </next>
  327. </block>
  328. </next>
  329. </block>
  330. </statement>
  331. </block>
  332. <block type="procedures_defreturn" inline="false" x="-3" y="1384">
  333. <mutation>
  334. <arg name="func x"></arg>
  335. <arg name="func y"></arg>
  336. </mutation>
  337. <field name="NAME">function 1</field>
  338. <statement name="STACK">
  339. <block type="variables_set" inline="false">
  340. <field name="VAR">func z</field>
  341. <value name="VALUE">
  342. <block type="text">
  343. <field name="TEXT">side effect</field>
  344. </block>
  345. </value>
  346. </block>
  347. </statement>
  348. <value name="RETURN">
  349. <block type="math_arithmetic" inline="true">
  350. <field name="OP">MINUS</field>
  351. <value name="A">
  352. <block type="variables_get">
  353. <field name="VAR">func x</field>
  354. </block>
  355. </value>
  356. <value name="B">
  357. <block type="variables_get">
  358. <field name="VAR">func y</field>
  359. </block>
  360. </value>
  361. </block>
  362. </value>
  363. </block>
  364. <block type="procedures_defreturn" inline="false" x="-1" y="1503">
  365. <mutation>
  366. <arg name="func a"></arg>
  367. </mutation>
  368. <field name="NAME">function 2</field>
  369. <statement name="STACK">
  370. <block type="math_change" inline="false">
  371. <field name="VAR">func a</field>
  372. <value name="DELTA">
  373. <block type="math_number">
  374. <field name="NUM">1</field>
  375. </block>
  376. </value>
  377. </block>
  378. </statement>
  379. <value name="RETURN">
  380. <block type="text_join" inline="false">
  381. <mutation items="2"></mutation>
  382. <value name="ADD0">
  383. <block type="variables_get">
  384. <field name="VAR">func a</field>
  385. </block>
  386. </value>
  387. <value name="ADD1">
  388. <block type="variables_get">
  389. <field name="VAR">func c</field>
  390. </block>
  391. </value>
  392. </block>
  393. </value>
  394. </block>
  395. <block type="procedures_defreturn" inline="false" x="0" y="1655">
  396. <mutation>
  397. <arg name="func a"></arg>
  398. </mutation>
  399. <field name="NAME">function 3</field>
  400. <statement name="STACK">
  401. <block type="procedures_ifreturn" inline="true">
  402. <mutation value="1"></mutation>
  403. <value name="CONDITION">
  404. <block type="variables_get">
  405. <field name="VAR">func a</field>
  406. </block>
  407. </value>
  408. <value name="VALUE">
  409. <block type="logic_boolean">
  410. <field name="BOOL">TRUE</field>
  411. </block>
  412. </value>
  413. </block>
  414. </statement>
  415. <value name="RETURN">
  416. <block type="logic_boolean">
  417. <field name="BOOL">FALSE</field>
  418. </block>
  419. </value>
  420. </block>
  421. <block type="procedures_defreturn" inline="false" x="0" y="1789">
  422. <mutation>
  423. <arg name="n"></arg>
  424. </mutation>
  425. <field name="NAME">recurse</field>
  426. <statement name="STACK">
  427. <block type="controls_if" inline="false">
  428. <mutation else="1"></mutation>
  429. <value name="IF0">
  430. <block type="logic_compare" inline="true">
  431. <field name="OP">GT</field>
  432. <value name="A">
  433. <block type="variables_get">
  434. <field name="VAR">n</field>
  435. </block>
  436. </value>
  437. <value name="B">
  438. <block type="math_number">
  439. <field name="NUM">0</field>
  440. </block>
  441. </value>
  442. </block>
  443. </value>
  444. <statement name="DO0">
  445. <block type="variables_set" inline="false">
  446. <field name="VAR">text</field>
  447. <value name="VALUE">
  448. <block type="text_join" inline="false">
  449. <mutation items="3"></mutation>
  450. <value name="ADD0">
  451. <block type="procedures_callreturn" inline="false">
  452. <mutation name="recurse">
  453. <arg name="n"></arg>
  454. </mutation>
  455. <value name="ARG0">
  456. <block type="math_arithmetic" inline="true">
  457. <field name="OP">MINUS</field>
  458. <value name="A">
  459. <block type="variables_get">
  460. <field name="VAR">n</field>
  461. </block>
  462. </value>
  463. <value name="B">
  464. <block type="math_number">
  465. <field name="NUM">1</field>
  466. </block>
  467. </value>
  468. </block>
  469. </value>
  470. </block>
  471. </value>
  472. <value name="ADD1">
  473. <block type="variables_get">
  474. <field name="VAR">n</field>
  475. </block>
  476. </value>
  477. <value name="ADD2">
  478. <block type="procedures_callreturn" inline="false">
  479. <mutation name="recurse">
  480. <arg name="n"></arg>
  481. </mutation>
  482. <value name="ARG0">
  483. <block type="math_arithmetic" inline="true">
  484. <field name="OP">MINUS</field>
  485. <value name="A">
  486. <block type="variables_get">
  487. <field name="VAR">n</field>
  488. </block>
  489. </value>
  490. <value name="B">
  491. <block type="math_number">
  492. <field name="NUM">1</field>
  493. </block>
  494. </value>
  495. </block>
  496. </value>
  497. </block>
  498. </value>
  499. </block>
  500. </value>
  501. </block>
  502. </statement>
  503. <statement name="ELSE">
  504. <block type="variables_set" inline="false">
  505. <field name="VAR">text</field>
  506. <value name="VALUE">
  507. <block type="text">
  508. <field name="TEXT">-</field>
  509. </block>
  510. </value>
  511. </block>
  512. </statement>
  513. </block>
  514. </statement>
  515. <value name="RETURN">
  516. <block type="variables_get">
  517. <field name="VAR">text</field>
  518. </block>
  519. </value>
  520. </block>
  521. </xml>