Advertisement
VladNitu

teste parser 13pct fp

Mar 16th, 2024
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. # Tests are groups of three lines: program, input, expected output
  2. # Blank lines and lines starting with # are ignored
  3.  
  4. #
  5. # Simple value tests to check parser. Input is irrelevant
  6. #
  7.  
  8. .
  9. null
  10. null
  11.  
  12. #
  13. # Double number test
  14. #
  15. .
  16. 12.014
  17. 12.014
  18.  
  19.  
  20. #
  21. # Double scientific notation no sign
  22. #
  23. .
  24. 1e10
  25. 1.0e10
  26.  
  27.  
  28. #
  29. # Double scientific notation + no sign (default +1)
  30. #
  31. .
  32. 23.5E1
  33. 235.0
  34.  
  35. #
  36. # Double scientific notation + sign larger
  37. #
  38. .
  39. 23.5E+12
  40. 2.35E+13
  41.  
  42. #
  43. # Double scientific notation - sign
  44. #
  45. .
  46. 1E-13
  47. 1.0E-13
  48.  
  49. #
  50. # Integer number test
  51. #
  52. .
  53. 123
  54. 123
  55.  
  56. #
  57. # String test basic
  58. #
  59. .
  60. "test string"
  61. "test string"
  62.  
  63. #
  64. # String test escape chars
  65. #
  66. .
  67. "\"Hello World\""
  68. "\"Hello World\""
  69.  
  70. #
  71. # String test number
  72. #
  73. .
  74. "123"
  75. "123"
  76.  
  77. #
  78. # Test floats
  79. #
  80. .
  81. 0.5
  82. 0.5
  83.  
  84. #
  85. # Tests w/ negative floats
  86. #
  87. .
  88. -1.5
  89. -1.5
  90.  
  91. # Test w/ arrays (basic)
  92. #
  93. .
  94. [1,2,3]
  95. [1,2,3]
  96.  
  97.  
  98. # Test w/ empty array
  99. #
  100. .
  101. []
  102. []
  103.  
  104. # Test w/ arrays + spaces
  105. #
  106. .
  107. [1, 2 ,3]
  108. [1,2,3]
  109.  
  110. # Test w/ arrays w/ multiple types of elements
  111. #
  112. .
  113. [1, -1.5 ,"abc"]
  114. [1,-1.5,"abc"]
  115.  
  116. # Test w/ spaces before arrays
  117. #
  118. .
  119. [1, -1.5 ,"abc"]
  120. [1,-1.5,"abc"]
  121.  
  122. # Test JObject basic (1 el)
  123. #
  124. #
  125. .
  126. {"a":1}
  127. {"a":1}
  128.  
  129. # Test JObject basic (>1 diff elements) + spaces
  130. #
  131. #
  132. .
  133. {"a":1, "b": 2, "c": "abc"}
  134. {"a":1,"b":2,"c":"abc"}
  135.  
  136. # Test JObject basic empty arr
  137. #
  138. #
  139. .
  140. {}
  141. {}
  142.  
  143. # Test JObject with Object with JArray
  144. #
  145. #
  146. .
  147. {"a":1, "b": 2, "c": [1, 2, 3]}
  148. {"a":1,"b":2,"c":[1,2,3]}
  149.  
  150.  
  151. #
  152. # String test control char
  153. #
  154. .
  155. "\u2600"
  156. "\"\9728\"\n"
  157.  
  158. #
  159. # Test weird string
  160. #
  161. .
  162. "Aa\r\n\t\b\f"
  163. "\"Aa\\r\\n\\t\\b\\f\"\n"
  164.  
  165.  
  166. #
  167. # True test
  168. #
  169. .
  170. true
  171. true
  172.  
  173. #
  174. # False test
  175. #
  176. .
  177. false
  178. false
  179.  
  180. #
  181. # Field access, piping
  182. #
  183.  
  184. .foo
  185. {"foo": 42, "bar": 43}
  186. 42
  187.  
  188. .foo | .bar
  189. {"foo": {"bar": 42}, "bar": "badvalue"}
  190. 42
  191.  
  192. .foo.bar
  193. {"foo": {"bar": 42}, "bar": "badvalue"}
  194. 42
  195.  
  196. .foo_bar
  197. {"foo_bar": 2}
  198. 2
  199.  
  200. .["foo"].bar
  201. {"foo": {"bar": 42}, "bar": "badvalue"}
  202. 42
  203.  
  204. ."foo"."bar"
  205. {"foo": {"bar": 20}}
  206. 20
  207.  
  208.  
  209. # Arrays
  210.  
  211. [.[]|.foo?]
  212. [1,[2],{"foo":3,"bar":4},{},{"foo":5}]
  213. [3,null,5]
  214.  
  215. [.[]|.foo?.bar?]
  216. [1,[2],[],{"foo":3},{"foo":{"bar":4}},{}]
  217. [4,null]
  218.  
  219. [.[]|.[]?]
  220. [1,null,[],[1,[2,[[3]]]],[{}],[{"a":[1,[2]]}]]
  221. [1,[2,[[3]]],{},{"a":[1,[2]]}]
  222.  
  223. [.[]|.[1:3]?]
  224. [1,null,true,false,"abcdef",{},{"a":1,"b":2},[],[1,2,3,4,5],[1,2]]
  225. [null,"bc",[],[2,3],[2]]
  226.  
  227. # Value construction
  228.  
  229. true
  230. null
  231. true
  232.  
  233. false
  234. null
  235. false
  236.  
  237. null
  238. 42
  239. null
  240.  
  241. 1
  242. null
  243. 1
  244.  
  245.  
  246. -1
  247. null
  248. -1
  249.  
  250. {}
  251. null
  252. {}
  253.  
  254. []
  255. null
  256. []
  257.  
  258. {x: -1}
  259. null
  260. {"x": -1}
  261.  
  262.  
  263. #
  264. # Dictionary construction syntax
  265. #
  266.  
  267. {a: 1}
  268. null
  269. {"a":1}
  270.  
  271. {a,b,(.d):.a,e:.b}
  272. {"a":1, "b":2, "c":3, "d":"c"}
  273. {"a":1, "b":2, "c":1, "e":2}
  274.  
  275. {"a",b,"a$2"}
  276. {"a":1, "b":2, "c":3, "a$2":4}
  277. {"a":1, "b":2, "a$2":4}
  278.  
  279. #
  280. # Unicode input
  281. #
  282. # unicode tests are particularly finicky depending on the encoding/OS/terminal
  283. # if the grading tests say you're deadling with unicode just fine
  284. # then you can safely ignore the tests below
  285. # but if you are missing points during grading these might help to debug your project
  286.  
  287. .
  288. "\b\r\f\t\n\r\u02ac\u058E\u05d2\u0606"
  289. "\b\r\f\t\n\rʬ֎ג؆"
  290.  
  291. .
  292. "\u0000"
  293. "\u0000"
  294.  
  295. #
  296. # Null input
  297. #
  298.  
  299. .[0:10]
  300. null
  301. null
  302.  
  303. .[0:10]?
  304. null
  305. null
  306.  
  307. .[0]
  308. null
  309. null
  310.  
  311. .[0]?
  312. null
  313. null
  314.  
  315. .["foo"]
  316. null
  317. null
  318.  
  319. .["foo"]?
  320. null
  321. null
  322.  
  323. .foo
  324. null
  325. null
  326.  
  327. .foo?
  328. null
  329. null
  330.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement