functions.xml 21 KB

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