test_constructors_models.py 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  1. import unittest
  2. import sys
  3. import os
  4. from utils import execute, kill, run_file, run_barebone
  5. def flatten(lst):
  6. new_lst = []
  7. for f in lst:
  8. if isinstance(f, (list, tuple)):
  9. new_lst.extend(flatten(f))
  10. else:
  11. new_lst.append(f)
  12. return new_lst
  13. bottom = [
  14. '"model"',
  15. '"instantiate_bottom"', 1,
  16. '"add_node"', 1, '"Class"',
  17. '"add_node"', 1, '"Type"',
  18. '"add_node"', 1, '"Any"',
  19. '"add_node"', 1, '"String"',
  20. '"add_value"', 1, '"inheritance"', '"inheritance"',
  21. '"add_value"', 1, '"link"', '"link"',
  22. '"add_value"', 1, '"name"', '"name"',
  23. '"add_edge"', 1, '"l1"', '"Class"', '"Any"',
  24. '"add_edge"', 1, '"l2"', '"Type"', '"Any"',
  25. '"add_edge"', 1, '"l3"', '"Any"', '"Any"',
  26. '"add_edge"', 1, '"l4"', '"l3"', '"inheritance"',
  27. '"add_edge"', 1, '"l5"', '"Any"', '"Any"',
  28. '"add_edge"', 1, '"l6"', '"l5"', '"Any"',
  29. '"add_edge"', 1, '"l7"', '"l5"', '"link"',
  30. '"add_edge"', 1, '"l8"', '"l5"', '"String"',
  31. '"add_edge"', 1, '"l9"', '"l8"', '"name"',
  32. '"exit"',
  33. ]
  34. retype = [
  35. '"model"',
  36. '"retype_model"', 1, 1,
  37. '"define_inheritance"', 1, '"l3"',
  38. '"retype"', 1, '"Class"', '"Class"',
  39. '"retype"', 1, '"Type"', '"Class"',
  40. '"retype"', 1, '"Any"', '"Class"',
  41. '"retype"', 1, '"String"', '"Type"',
  42. '"retype"', 1, '"inheritance"', '"String"',
  43. '"retype"', 1, '"link"', '"String"',
  44. '"retype"', 1, '"name"', '"String"',
  45. '"retype"', 1, '"l1"', '"l3"',
  46. '"retype"', 1, '"l2"', '"l3"',
  47. '"retype"', 1, '"l3"', '"l5"',
  48. '"retype"', 1, '"l4"', '"l8"',
  49. '"retype"', 1, '"l5"', '"l5"',
  50. '"retype"', 1, '"l6"', '"l3"',
  51. '"retype"', 1, '"l7"', '"l8"',
  52. '"retype"', 1, '"l8"', '"l5"',
  53. '"retype"', 1, '"l9"', '"l8"',
  54. '"exit"',
  55. ]
  56. instantiate_scd = [
  57. '"model"',
  58. '"instantiate_model"', 1, 2,
  59. '"define_inheritance"', 2, '"l3"',
  60. '"instantiate_node"', 2, '"Class"', '"Place"',
  61. '"instantiate_node"', 2, '"Class"', '"Transition"',
  62. '"instantiate_node"', 2, '"Type"', '"Integer"',
  63. '"instantiate_link"', 2, '"l5"', '"P2T"', '"Place"', '"Transition"',
  64. '"instantiate_link"', 2, '"l5"', '"T2P"', '"Transition"', '"Place"',
  65. '"instantiate_named"', 2, '"l5"', '"tokens"', '"Place"', '"Integer"',
  66. '"instantiate_named"', 2, '"l5"', '"weight"', '"P2T"', '"Integer"',
  67. '"instantiate_named"', 2, '"l5"', '"weight"', '"T2P"', '"Integer"',
  68. '"exit"',
  69. ]
  70. instantiate_pn = [
  71. '"model"',
  72. '"instantiate_model"', 2, 3,
  73. '"instantiate_node"', 3, '"Place"', '"p1"',
  74. '"instantiate_node"', 3, '"Place"', '"p2"',
  75. '"instantiate_node"', 3, '"Transition"', '"t1"',
  76. '"instantiate_node"', 3, '"Transition"', '"t2"',
  77. '"instantiate_link"', 3, '"P2T"', '"p1_t1"', '"p1"', '"t1"',
  78. '"instantiate_link"', 3, '"T2P"', '"t1_p2"', '"t1"', '"p2"',
  79. '"instantiate_link"', 3, '"P2T"', '"p2_t2"', '"p2"', '"t2"',
  80. '"instantiate_link"', 3, '"T2P"', '"t2_p1"', '"t2"', '"p1"',
  81. '"instantiate_attribute"', 3, '"p1_t1"', '"weight"', '1',
  82. '"instantiate_attribute"', 3, '"t1_p2"', '"weight"', '2',
  83. '"instantiate_attribute"', 3, '"p2_t2"', '"weight"', '3',
  84. '"instantiate_attribute"', 3, '"t2_p1"', '"weight"', '4',
  85. '"instantiate_attribute"', 3, '"p1"', '"tokens"', '5',
  86. '"instantiate_attribute"', 3, '"p2"', '"tokens"', '6',
  87. '"exit"',
  88. ]
  89. def conformance_check(node):
  90. return [
  91. '"output"',
  92. '"call"',
  93. '"access"', '"resolve"', '"conformance_scd"',
  94. '1',
  95. '"const"', node,
  96. 'false',
  97. 'true',
  98. '"return"',
  99. 'false',
  100. ]
  101. class TestConstructorsModels(unittest.TestCase):
  102. def test_constructors_instantiate_bottom(self):
  103. commands = bottom + retype + conformance_check(1)
  104. self.assertTrue(run_barebone(commands, ["OK"], 1))
  105. def test_constructors_instantiate_scd(self):
  106. commands = bottom + retype + instantiate_scd + conformance_check(2)
  107. self.assertTrue(run_barebone(commands, ["OK"], 1))
  108. def test_constructors_instantiate_pn(self):
  109. commands = bottom + retype + instantiate_scd + instantiate_pn + conformance_check(3)
  110. self.assertTrue(run_barebone(commands, ["OK"], 1))
  111. """
  112. def test_constructors_instantiate_model(self):
  113. commands = bottom + [
  114. '"instantiate_model"',
  115. 1,
  116. 1, '"Inheritance"',
  117. '"Type"', '"Integer"',
  118. 'false',
  119. 'false',
  120. 'true',
  121. '"Class"', '"Place"',
  122. 'true',
  123. '"tokens"', '"Integer"', 'false',
  124. 'false',
  125. 'true',
  126. '"Class"', '"Transition"',
  127. 'false',
  128. 'false',
  129. 'true',
  130. '"Association"', '"P2T"', '"Place"', '"Transition"',
  131. 'true',
  132. '"weight"', '"Integer"', 'false',
  133. 'false',
  134. 'true',
  135. '"Association"', '"T2P"', '"Transition"', '"Place"',
  136. 'true',
  137. '"weight"', '"Integer"', 'false',
  138. 'false',
  139. 'false',
  140. 2,
  141. '"instantiate_model"',
  142. 2,
  143. 1, '"Inheritance"',
  144. '"Place"', '"p1"',
  145. 'false',
  146. 'true',
  147. '"tokens"', '5', 'false',
  148. 'true',
  149. '"Transition"', '"t1"',
  150. 'false',
  151. 'false',
  152. 'true',
  153. '"P2T"', '""', '"p1"', '"t1"',
  154. 'false',
  155. 'true',
  156. '"weight"', '1', 'false',
  157. 'true',
  158. '"T2P"', '""', '"t1"', '"p1"',
  159. 'false',
  160. 'true',
  161. '"weight"', '2', 'false',
  162. 'false',
  163. 3,
  164. '"output"', '"const"', '3',
  165. 'true',
  166. '"return"', 'true',
  167. '"const"', 'true',
  168. ]
  169. self.assertTrue(run_barebone(flatten(commands), ['3'], 1))
  170. def test_constructors_retype_model(self):
  171. commands = bottom + retype + [
  172. '"output"', '"const"', '3',
  173. 'true',
  174. '"return"', 'true',
  175. '"const"', 'true',
  176. ]
  177. self.assertTrue(run_barebone(flatten(commands), ['3'], 1))
  178. def test_constructors_instantiate_model_inheritance(self):
  179. commands = bottom + [
  180. '"instantiate_model"',
  181. 1,
  182. 1, '"Inheritance"',
  183. '"Class"', '"A"',
  184. 'true',
  185. '"a"', '{"value": "Integer"}', 'false',
  186. 'false',
  187. 'true',
  188. '"Class"', '"B"',
  189. 'true',
  190. '"b"', '{"value": "Integer"}', 'false',
  191. 'false',
  192. 'true',
  193. '"Inheritance"', '"b_inherits_from_a"', '"B"', '"A"',
  194. 'false',
  195. 'false',
  196. 'false',
  197. 2,
  198. '"instantiate_model"',
  199. 2,
  200. 1, '"Inheritance"',
  201. '"A"', '"a1"',
  202. 'false',
  203. 'true',
  204. '"a"', '1', 'false',
  205. 'true',
  206. '"B"', '"b1"',
  207. 'false',
  208. 'true',
  209. '"a"', '2', 'true',
  210. '"b"', '3', 'false',
  211. 'false',
  212. 3,
  213. '"output"', '"const"', '3',
  214. 'true',
  215. '"return"', 'true',
  216. '"const"', 'true',
  217. ]
  218. self.assertTrue(run_barebone(flatten(commands), ['3'], 1))
  219. def test_constructors_conformance_metametamodel(self):
  220. commands = bottom + retype + [
  221. '"output"', '"call"',
  222. '"access"',
  223. '"resolve"', '"conformance_scd"',
  224. '1',
  225. '"const"', 1,
  226. 'false',
  227. 'true',
  228. '"return"', 'true',
  229. '"const"', 'true',
  230. ]
  231. self.assertTrue(run_barebone(flatten(commands), ['OK'], 1))
  232. def test_constructors_conformance_metamodel(self):
  233. commands = bottom + retype + [
  234. '"instantiate_model"',
  235. 1,
  236. 1, '"Inheritance"',
  237. '"Class"', '"Place"',
  238. 'true',
  239. '"tokens"', '{"value": "Integer"}', 'false',
  240. 'false',
  241. 'true',
  242. '"Class"', '"Transition"',
  243. 'false',
  244. 'false',
  245. 'true',
  246. '"Association"', '"P2T"', '"Place"', '"Transition"',
  247. 'true',
  248. '"weight"', '{"value": "Integer"}', 'false',
  249. 'false',
  250. 'true',
  251. '"Association"', '"T2P"', '"Transition"', '"Place"',
  252. 'true',
  253. '"weight"', '{"value": "Integer"}', 'false',
  254. 'false',
  255. 'false',
  256. 2,
  257. '"output"', '"call"',
  258. '"access"',
  259. '"resolve"', '"conformance_scd"',
  260. '1',
  261. '"const"', 2,
  262. 'false',
  263. 'true',
  264. '"return"', 'true',
  265. '"const"', 'true',
  266. ]
  267. self.assertTrue(run_barebone(flatten(commands), ['OK'], 1))
  268. def test_constructors_conformance_model(self):
  269. commands = bottom + retype + [
  270. '"instantiate_model"',
  271. 1,
  272. 1, '"Inheritance"',
  273. '"Class"', '"Place"',
  274. 'true',
  275. '"tokens"', '{"value": "Integer"}', 'false',
  276. 'false',
  277. 'true',
  278. '"Class"', '"Transition"',
  279. 'false',
  280. 'false',
  281. 'true',
  282. '"Association"', '"P2T"', '"Place"', '"Transition"',
  283. 'true',
  284. '"weight"', '{"value": "Integer"}', 'false',
  285. 'false',
  286. 'true',
  287. '"Association"', '"T2P"', '"Transition"', '"Place"',
  288. 'true',
  289. '"weight"', '{"value": "Integer"}', 'false',
  290. 'false',
  291. 'false',
  292. 2,
  293. '"instantiate_model"',
  294. 2,
  295. 1, '"Inheritance"',
  296. '"Place"', '"p1"',
  297. 'false',
  298. 'true',
  299. '"tokens"', '5', 'false',
  300. 'true',
  301. '"Transition"', '"t1"',
  302. 'false',
  303. 'false',
  304. 'true',
  305. '"P2T"', '""', '"p1"', '"t1"',
  306. 'false',
  307. 'true',
  308. '"weight"', '1', 'false',
  309. 'true',
  310. '"T2P"', '""', '"t1"', '"p1"',
  311. 'false',
  312. 'true',
  313. '"weight"', '2', 'false',
  314. 'false',
  315. 3,
  316. '"output"', '"call"',
  317. '"access"',
  318. '"resolve"', '"conformance_scd"',
  319. '1',
  320. '"const"', 3,
  321. 'false',
  322. 'true',
  323. '"return"', 'true',
  324. '"const"', 'true',
  325. ]
  326. self.assertTrue(run_barebone(flatten(commands), ['OK'], 1))
  327. def test_constructors_is_direct_instance(self):
  328. commands = bottom + retype + [
  329. '"instantiate_model"',
  330. 1,
  331. 1, '"Inheritance"',
  332. '"Class"', '"A"',
  333. 'true',
  334. '"a"', '{"value": "Integer"}', 'false',
  335. 'false',
  336. 'true',
  337. '"Class"', '"B"',
  338. 'true',
  339. '"b"', '{"value": "Integer"}', 'false',
  340. 'false',
  341. 'true',
  342. '"Class"', '"C"',
  343. 'true',
  344. '"b"', '{"value": "Integer"}', 'true',
  345. '"c"', '{"value": "Integer"}', 'false',
  346. 'false',
  347. 'true',
  348. '"Inheritance"', '"__inh_1"', '"A"', '"B"',
  349. 'false',
  350. 'false',
  351. 'false',
  352. 2,
  353. '"instantiate_model"',
  354. 2,
  355. 1, '"Inheritance"',
  356. '"A"', '"a"',
  357. 'false',
  358. 'true',
  359. '"a"', '1', 'true',
  360. '"b"', '1', 'false',
  361. 'true',
  362. '"B"', '"b"',
  363. 'false',
  364. 'true',
  365. '"b"', '1', 'false',
  366. 'true',
  367. '"C"', '"c"',
  368. 'false',
  369. 'true',
  370. '"b"', '1', 'true',
  371. '"c"', '1', 'false',
  372. 'false',
  373. 3,
  374. ] + \
  375. function_call("is_direct_instance", "a", "A") + \
  376. function_call("is_direct_instance", "a", "B") + \
  377. function_call("is_direct_instance", "a", "C") + \
  378. function_call("is_direct_instance", "b", "A") + \
  379. function_call("is_direct_instance", "b", "B") + \
  380. function_call("is_direct_instance", "b", "C") + \
  381. function_call("is_direct_instance", "c", "A") + \
  382. function_call("is_direct_instance", "c", "B") + \
  383. function_call("is_direct_instance", "c", "C") + \
  384. ['"return"', 'true',
  385. '"const"', 'true',
  386. ]
  387. # Test in order:
  388. # a : A --> Yes
  389. # a : B --> No
  390. # a : C --> No
  391. # b : A --> No
  392. # b : B --> Yes
  393. # b : C --> No
  394. # c : A --> No
  395. # c : B --> No
  396. # c : C --> Yes
  397. self.assertTrue(run_barebone(flatten(commands), ['True', 'False', 'False', 'False', 'True', 'False', 'False', 'False', 'True'], 1))
  398. def test_constructors_is_nominal_instance(self):
  399. commands = bottom + retype + [
  400. '"instantiate_model"',
  401. 1,
  402. 1, '"Inheritance"',
  403. '"Class"', '"A"',
  404. 'true',
  405. '"a"', '{"value": "Integer"}', 'false',
  406. 'false',
  407. 'true',
  408. '"Class"', '"B"',
  409. 'true',
  410. '"b"', '{"value": "Integer"}', 'false',
  411. 'false',
  412. 'true',
  413. '"Class"', '"C"',
  414. 'true',
  415. '"b"', '{"value": "Integer"}', 'true',
  416. '"c"', '{"value": "Integer"}', 'false',
  417. 'false',
  418. 'true',
  419. '"Inheritance"', '"__inh_1"', '"A"', '"B"',
  420. 'false',
  421. 'false',
  422. 'false',
  423. 2,
  424. '"instantiate_model"',
  425. 2,
  426. 1, '"Inheritance"',
  427. '"A"', '"a"',
  428. 'false',
  429. 'true',
  430. '"a"', '1', 'true',
  431. '"b"', '1', 'false',
  432. 'true',
  433. '"B"', '"b"',
  434. 'false',
  435. 'true',
  436. '"b"', '1', 'false',
  437. 'true',
  438. '"C"', '"c"',
  439. 'false',
  440. 'true',
  441. '"b"', '1', 'true',
  442. '"c"', '1', 'false',
  443. 'false',
  444. 3, ] + \
  445. function_call("is_nominal_instance", "a", "A") + \
  446. function_call("is_nominal_instance", "a", "B") + \
  447. function_call("is_nominal_instance", "a", "C") + \
  448. function_call("is_nominal_instance", "b", "A") + \
  449. function_call("is_nominal_instance", "b", "B") + \
  450. function_call("is_nominal_instance", "b", "C") + \
  451. function_call("is_nominal_instance", "c", "A") + \
  452. function_call("is_nominal_instance", "c", "B") + \
  453. function_call("is_nominal_instance", "c", "C") + \
  454. [ '"return"', 'true',
  455. '"const"', 'true',
  456. ]
  457. # Test in order:
  458. # a : A --> Yes
  459. # a : B --> Yes
  460. # a : C --> No
  461. # b : A --> No
  462. # b : B --> Yes
  463. # b : C --> No
  464. # c : A --> No
  465. # c : B --> No
  466. # c : C --> Yes
  467. self.assertTrue(run_barebone(flatten(commands), ['True', 'True', 'False', 'False', 'True', 'False', 'False', 'False', 'True'], 1))
  468. def test_constructors_is_structural_instance(self):
  469. commands = bottom + retype + [
  470. '"instantiate_model"',
  471. 1,
  472. 1, '"Inheritance"',
  473. '"Class"', '"A"',
  474. 'true',
  475. '"a"', '{"value": "Integer"}', 'false',
  476. 'false',
  477. 'true',
  478. '"Class"', '"B"',
  479. 'true',
  480. '"b"', '{"value": "Integer"}', 'false',
  481. 'false',
  482. 'true',
  483. '"Class"', '"C"',
  484. 'true',
  485. '"b"', '{"value": "Integer"}', 'true',
  486. '"c"', '{"value": "Integer"}', 'false',
  487. 'false',
  488. 'true',
  489. '"Inheritance"', '"__inh_1"', '"A"', '"B"',
  490. 'false',
  491. 'false',
  492. 'false',
  493. 2,
  494. '"instantiate_model"',
  495. 2,
  496. 1, '"Inheritance"',
  497. '"A"', '"a"',
  498. 'false',
  499. 'true',
  500. '"a"', '1', 'false',
  501. 'true',
  502. '"B"', '"b"',
  503. 'false',
  504. 'true',
  505. '"b"', '1', 'false',
  506. 'true',
  507. '"C"', '"c"',
  508. 'false',
  509. 'true',
  510. '"b"', '1', 'true',
  511. '"c"', '1', 'false',
  512. 'false',
  513. 3, ] + \
  514. function_call("is_structural_instance", "a", "A") + \
  515. function_call("is_structural_instance", "a", "B") + \
  516. function_call("is_structural_instance", "a", "C") + \
  517. function_call("is_structural_instance", "b", "A") + \
  518. function_call("is_structural_instance", "b", "B") + \
  519. function_call("is_structural_instance", "b", "C") + \
  520. function_call("is_structural_instance", "c", "A") + \
  521. function_call("is_structural_instance", "c", "B") + \
  522. function_call("is_structural_instance", "c", "C") + \
  523. [ '"return"', 'true',
  524. '"const"', 'true',
  525. ]
  526. # Test in order:
  527. # a : A --> Yes
  528. # a : B --> No
  529. # a : C --> No
  530. # b : A --> No
  531. # b : B --> Yes
  532. # b : C --> No
  533. # c : A --> No
  534. # c : B --> Yes
  535. # c : C --> Yes
  536. self.assertTrue(run_barebone(flatten(commands), ['True', 'False', 'False', 'False', 'True', 'False', 'False', 'True', 'True'], 1))
  537. def test_constructors_readAttribute(self):
  538. commands = bottom + retype + [
  539. '"instantiate_model"',
  540. 1,
  541. 1, '"Inheritance"',
  542. '"Class"', '"Place"',
  543. 'true',
  544. '"tokens"', '{"value": "Integer"}', 'false',
  545. 'false',
  546. 'true',
  547. '"Class"', '"Transition"',
  548. 'false',
  549. 'false',
  550. 'true',
  551. '"Association"', '"P2T"', '"Place"', '"Transition"',
  552. 'true',
  553. '"weight"', '{"value": "Integer"}', 'false',
  554. 'false',
  555. 'true',
  556. '"Association"', '"T2P"', '"Transition"', '"Place"',
  557. 'true',
  558. '"weight"', '{"value": "Integer"}', 'false',
  559. 'false',
  560. 'false',
  561. 2,
  562. '"instantiate_model"',
  563. 2,
  564. 1, '"Inheritance"',
  565. '"Place"', '"p1"',
  566. 'false',
  567. 'true',
  568. '"tokens"', '5', 'false',
  569. 'true',
  570. '"Transition"', '"t1"',
  571. 'false',
  572. 'false',
  573. 'true',
  574. '"P2T"', '"arc1"', '"p1"', '"t1"',
  575. 'false',
  576. 'true',
  577. '"weight"', '1', 'false',
  578. 'true',
  579. '"T2P"', '"arc2"', '"t1"', '"p1"',
  580. 'false',
  581. 'true',
  582. '"weight"', '2', 'false',
  583. 'false',
  584. 3,
  585. '"output"', '"call"',
  586. '"access"',
  587. '"resolve"', '"readAttribute"',
  588. '3',
  589. '"const"', 3,
  590. '"call"',
  591. '"access"',
  592. '"resolve"', '"readElementByName"',
  593. '2',
  594. '"const"', 3,
  595. '"const"', '"p1"',
  596. 'false',
  597. '"const"', '"tokens"',
  598. 'false',
  599. 'true',
  600. '"output"', '"call"',
  601. '"access"',
  602. '"resolve"', '"readAttribute"',
  603. '3',
  604. '"const"', 3,
  605. '"call"',
  606. '"access"',
  607. '"resolve"', '"readElementByName"',
  608. '2',
  609. '"const"', 3,
  610. '"const"', '"arc1"',
  611. 'false',
  612. '"const"', '"weight"',
  613. 'false',
  614. 'true',
  615. '"output"', '"call"',
  616. '"access"',
  617. '"resolve"', '"readAttribute"',
  618. '3',
  619. '"const"', 3,
  620. '"call"',
  621. '"access"',
  622. '"resolve"', '"readElementByName"',
  623. '2',
  624. '"const"', 3,
  625. '"const"', '"arc2"',
  626. 'false',
  627. '"const"', '"weight"',
  628. 'false',
  629. 'true',
  630. '"return"', 'true',
  631. '"const"', 'true',
  632. ]
  633. self.assertTrue(run_barebone(flatten(commands), ['5', '1', '2'], 1))
  634. def test_constructors_readAndSetAttribute(self):
  635. commands = bottom + retype + [
  636. '"instantiate_model"',
  637. 1,
  638. 1, '"Inheritance"',
  639. '"Class"', '"Place"',
  640. 'true',
  641. '"tokens"', '{"value": "Integer"}', 'false',
  642. 'false',
  643. 'true',
  644. '"Class"', '"Transition"',
  645. 'false',
  646. 'false',
  647. 'true',
  648. '"Association"', '"P2T"', '"Place"', '"Transition"',
  649. 'true',
  650. '"weight"', '{"value": "Integer"}', 'false',
  651. 'false',
  652. 'true',
  653. '"Association"', '"T2P"', '"Transition"', '"Place"',
  654. 'true',
  655. '"weight"', '{"value": "Integer"}', 'false',
  656. 'false',
  657. 'false',
  658. 2,
  659. '"instantiate_model"',
  660. 2,
  661. 1, '"Inheritance"',
  662. '"Place"', '"p1"',
  663. 'false',
  664. 'true',
  665. '"tokens"', '5', 'false',
  666. 'true',
  667. '"Transition"', '"t1"',
  668. 'false',
  669. 'false',
  670. 'true',
  671. '"P2T"', '"arc1"', '"p1"', '"t1"',
  672. 'false',
  673. 'true',
  674. '"weight"', '1', 'false',
  675. 'true',
  676. '"T2P"', '"arc2"', '"t1"', '"p1"',
  677. 'false',
  678. 'true',
  679. '"weight"', '2', 'false',
  680. 'false',
  681. 3,
  682. '"output"', '"call"',
  683. '"access"',
  684. '"resolve"', '"readAttribute"',
  685. '3',
  686. '"const"', 3,
  687. '"call"',
  688. '"access"',
  689. '"resolve"', '"readElementByName"',
  690. '2',
  691. '"const"', 3,
  692. '"const"', '"p1"',
  693. 'false',
  694. '"const"', '"tokens"',
  695. 'false',
  696. 'true',
  697. '"output"', '"call"',
  698. '"access"',
  699. '"resolve"', '"readAttribute"',
  700. '3',
  701. '"const"', 3,
  702. '"call"',
  703. '"access"',
  704. '"resolve"', '"readElementByName"',
  705. '2',
  706. '"const"', 3,
  707. '"const"', '"arc1"',
  708. 'false',
  709. '"const"', '"weight"',
  710. 'false',
  711. 'true',
  712. '"output"', '"call"',
  713. '"access"',
  714. '"resolve"', '"readAttribute"',
  715. '3',
  716. '"const"', 3,
  717. '"call"',
  718. '"access"',
  719. '"resolve"', '"readElementByName"',
  720. '2',
  721. '"const"', 3,
  722. '"const"', '"arc2"',
  723. 'false',
  724. '"const"', '"weight"',
  725. 'false',
  726. 'true',
  727. '"call"',
  728. '"access"',
  729. '"resolve"', '"setAttribute"',
  730. '4',
  731. '"const"', 3,
  732. '"call"',
  733. '"access"',
  734. '"resolve"', '"readElementByName"',
  735. '2',
  736. '"const"', 3,
  737. '"const"', '"p1"',
  738. 'false',
  739. '"const"', '"tokens"',
  740. '"const"', '10',
  741. 'true',
  742. '"call"',
  743. '"access"',
  744. '"resolve"', '"setAttribute"',
  745. '4',
  746. '"const"', 3,
  747. '"call"',
  748. '"access"',
  749. '"resolve"', '"readElementByName"',
  750. '2',
  751. '"const"', 3,
  752. '"const"', '"arc1"',
  753. 'false',
  754. '"const"', '"weight"',
  755. '"const"', '16',
  756. 'true',
  757. '"call"',
  758. '"access"',
  759. '"resolve"', '"setAttribute"',
  760. '4',
  761. '"const"', 3,
  762. '"call"',
  763. '"access"',
  764. '"resolve"', '"readElementByName"',
  765. '2',
  766. '"const"', 3,
  767. '"const"', '"arc2"',
  768. 'false',
  769. '"const"', '"weight"',
  770. '"const"', '30',
  771. 'true',
  772. '"output"', '"call"',
  773. '"access"',
  774. '"resolve"', '"readAttribute"',
  775. '3',
  776. '"const"', 3,
  777. '"call"',
  778. '"access"',
  779. '"resolve"', '"readElementByName"',
  780. '2',
  781. '"const"', 3,
  782. '"const"', '"p1"',
  783. 'false',
  784. '"const"', '"tokens"',
  785. 'false',
  786. 'true',
  787. '"output"', '"call"',
  788. '"access"',
  789. '"resolve"', '"readAttribute"',
  790. '3',
  791. '"const"', 3,
  792. '"call"',
  793. '"access"',
  794. '"resolve"', '"readElementByName"',
  795. '2',
  796. '"const"', 3,
  797. '"const"', '"arc1"',
  798. 'false',
  799. '"const"', '"weight"',
  800. 'false',
  801. 'true',
  802. '"output"', '"call"',
  803. '"access"',
  804. '"resolve"', '"readAttribute"',
  805. '3',
  806. '"const"', 3,
  807. '"call"',
  808. '"access"',
  809. '"resolve"', '"readElementByName"',
  810. '2',
  811. '"const"', 3,
  812. '"const"', '"arc2"',
  813. 'false',
  814. '"const"', '"weight"',
  815. 'false',
  816. 'true',
  817. '"return"', 'true',
  818. '"const"', 'true',
  819. ]
  820. self.assertTrue(run_barebone(flatten(commands), ['5', '1', '2', '10', '16', '30'], 1))
  821. """