You are here

YtsSpecificationExamples.yml in Service Container 7.2

modules/providers/service_container_symfony/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml

File

modules/providers/service_container_symfony/lib/Symfony/Component/Yaml/Tests/Fixtures/YtsSpecificationExamples.yml
View source
  1. --- %YAML:1.0
  2. test: Sequence of scalars
  3. spec: 2.1
  4. yaml: |
  5. - Mark McGwire
  6. - Sammy Sosa
  7. - Ken Griffey
  8. php: |
  9. array('Mark McGwire', 'Sammy Sosa', 'Ken Griffey')
  10. ---
  11. test: Mapping of scalars to scalars
  12. spec: 2.2
  13. yaml: |
  14. hr: 65
  15. avg: 0.278
  16. rbi: 147
  17. php: |
  18. array('hr' => 65, 'avg' => 0.278, 'rbi' => 147)
  19. ---
  20. test: Mapping of scalars to sequences
  21. spec: 2.3
  22. yaml: |
  23. american:
  24. - Boston Red Sox
  25. - Detroit Tigers
  26. - New York Yankees
  27. national:
  28. - New York Mets
  29. - Chicago Cubs
  30. - Atlanta Braves
  31. php: |
  32. array('american' =>
  33. array( 'Boston Red Sox', 'Detroit Tigers',
  34. 'New York Yankees' ),
  35. 'national' =>
  36. array( 'New York Mets', 'Chicago Cubs',
  37. 'Atlanta Braves' )
  38. )
  39. ---
  40. test: Sequence of mappings
  41. spec: 2.4
  42. yaml: |
  43. -
  44. name: Mark McGwire
  45. hr: 65
  46. avg: 0.278
  47. -
  48. name: Sammy Sosa
  49. hr: 63
  50. avg: 0.288
  51. php: |
  52. array(
  53. array('name' => 'Mark McGwire', 'hr' => 65, 'avg' => 0.278),
  54. array('name' => 'Sammy Sosa', 'hr' => 63, 'avg' => 0.288)
  55. )
  56. ---
  57. test: Legacy A5
  58. todo: true
  59. spec: legacy_A5
  60. yaml: |
  61. ?
  62. - New York Yankees
  63. - Atlanta Braves
  64. :
  65. - 2001-07-02
  66. - 2001-08-12
  67. - 2001-08-14
  68. ?
  69. - Detroit Tigers
  70. - Chicago Cubs
  71. :
  72. - 2001-07-23
  73. perl-busted: >
  74. YAML.pm will be able to emulate this behavior soon. In this regard
  75. it may be somewhat more correct than Python's native behaviour which
  76. can only use tuples as mapping keys. PyYAML will also need to figure
  77. out some clever way to roundtrip structured keys.
  78. python: |
  79. [
  80. {
  81. ('New York Yankees', 'Atlanta Braves'):
  82. [yaml.timestamp('2001-07-02'),
  83. yaml.timestamp('2001-08-12'),
  84. yaml.timestamp('2001-08-14')],
  85. ('Detroit Tigers', 'Chicago Cubs'):
  86. [yaml.timestamp('2001-07-23')]
  87. }
  88. ]
  89. ruby: |
  90. {
  91. [ 'New York Yankees', 'Atlanta Braves' ] =>
  92. [ Date.new( 2001, 7, 2 ), Date.new( 2001, 8, 12 ), Date.new( 2001, 8, 14 ) ],
  93. [ 'Detroit Tigers', 'Chicago Cubs' ] =>
  94. [ Date.new( 2001, 7, 23 ) ]
  95. }
  96. syck: |
  97. struct test_node seq1[] = {
  98. { T_STR, 0, "New York Yankees" },
  99. { T_STR, 0, "Atlanta Braves" },
  100. end_node
  101. };
  102. struct test_node seq2[] = {
  103. { T_STR, 0, "2001-07-02" },
  104. { T_STR, 0, "2001-08-12" },
  105. { T_STR, 0, "2001-08-14" },
  106. end_node
  107. };
  108. struct test_node seq3[] = {
  109. { T_STR, 0, "Detroit Tigers" },
  110. { T_STR, 0, "Chicago Cubs" },
  111. end_node
  112. };
  113. struct test_node seq4[] = {
  114. { T_STR, 0, "2001-07-23" },
  115. end_node
  116. };
  117. struct test_node map[] = {
  118. { T_SEQ, 0, 0, seq1 },
  119. { T_SEQ, 0, 0, seq2 },
  120. { T_SEQ, 0, 0, seq3 },
  121. { T_SEQ, 0, 0, seq4 },
  122. end_node
  123. };
  124. struct test_node stream[] = {
  125. { T_MAP, 0, 0, map },
  126. end_node
  127. };
  128. ---
  129. test: Sequence of sequences
  130. spec: 2.5
  131. yaml: |
  132. - [ name , hr , avg ]
  133. - [ Mark McGwire , 65 , 0.278 ]
  134. - [ Sammy Sosa , 63 , 0.288 ]
  135. php: |
  136. array(
  137. array( 'name', 'hr', 'avg' ),
  138. array( 'Mark McGwire', 65, 0.278 ),
  139. array( 'Sammy Sosa', 63, 0.288 )
  140. )
  141. ---
  142. test: Mapping of mappings
  143. todo: true
  144. spec: 2.6
  145. yaml: |
  146. Mark McGwire: {hr: 65, avg: 0.278}
  147. Sammy Sosa: {
  148. hr: 63,
  149. avg: 0.288
  150. }
  151. php: |
  152. array(
  153. 'Mark McGwire' =>
  154. array( 'hr' => 65, 'avg' => 0.278 ),
  155. 'Sammy Sosa' =>
  156. array( 'hr' => 63, 'avg' => 0.288 )
  157. )
  158. ---
  159. test: Two documents in a stream each with a leading comment
  160. todo: true
  161. spec: 2.7
  162. yaml: |
  163. # Ranking of 1998 home runs
  164. ---
  165. - Mark McGwire
  166. - Sammy Sosa
  167. - Ken Griffey
  168. # Team ranking
  169. ---
  170. - Chicago Cubs
  171. - St Louis Cardinals
  172. ruby: |
  173. y = YAML::Stream.new
  174. y.add( [ 'Mark McGwire', 'Sammy Sosa', 'Ken Griffey' ] )
  175. y.add( [ 'Chicago Cubs', 'St Louis Cardinals' ] )
  176. documents: 2
  177. ---
  178. test: Play by play feed from a game
  179. todo: true
  180. spec: 2.8
  181. yaml: |
  182. ---
  183. time: 20:03:20
  184. player: Sammy Sosa
  185. action: strike (miss)
  186. ...
  187. ---
  188. time: 20:03:47
  189. player: Sammy Sosa
  190. action: grand slam
  191. ...
  192. perl: |
  193. [ 'Mark McGwire', 'Sammy Sosa', 'Ken Griffey' ]
  194. documents: 2
  195. ---
  196. test: Single document with two comments
  197. spec: 2.9
  198. yaml: |
  199. hr: # 1998 hr ranking
  200. - Mark McGwire
  201. - Sammy Sosa
  202. rbi:
  203. # 1998 rbi ranking
  204. - Sammy Sosa
  205. - Ken Griffey
  206. php: |
  207. array(
  208. 'hr' => array( 'Mark McGwire', 'Sammy Sosa' ),
  209. 'rbi' => array( 'Sammy Sosa', 'Ken Griffey' )
  210. )
  211. ---
  212. test: Node for Sammy Sosa appears twice in this document
  213. spec: 2.10
  214. yaml: |
  215. ---
  216. hr:
  217. - Mark McGwire
  218. # Following node labeled SS
  219. - &SS Sammy Sosa
  220. rbi:
  221. - *SS # Subsequent occurrence
  222. - Ken Griffey
  223. php: |
  224. array(
  225. 'hr' =>
  226. array('Mark McGwire', 'Sammy Sosa'),
  227. 'rbi' =>
  228. array('Sammy Sosa', 'Ken Griffey')
  229. )
  230. ---
  231. test: Mapping between sequences
  232. todo: true
  233. spec: 2.11
  234. yaml: |
  235. ? # PLAY SCHEDULE
  236. - Detroit Tigers
  237. - Chicago Cubs
  238. :
  239. - 2001-07-23
  240. ? [ New York Yankees,
  241. Atlanta Braves ]
  242. : [ 2001-07-02, 2001-08-12,
  243. 2001-08-14 ]
  244. ruby: |
  245. {
  246. [ 'Detroit Tigers', 'Chicago Cubs' ] => [ Date.new( 2001, 7, 23 ) ],
  247. [ 'New York Yankees', 'Atlanta Braves' ] => [ Date.new( 2001, 7, 2 ), Date.new( 2001, 8, 12 ), Date.new( 2001, 8, 14 ) ]
  248. }
  249. syck: |
  250. struct test_node seq1[] = {
  251. { T_STR, 0, "New York Yankees" },
  252. { T_STR, 0, "Atlanta Braves" },
  253. end_node
  254. };
  255. struct test_node seq2[] = {
  256. { T_STR, 0, "2001-07-02" },
  257. { T_STR, 0, "2001-08-12" },
  258. { T_STR, 0, "2001-08-14" },
  259. end_node
  260. };
  261. struct test_node seq3[] = {
  262. { T_STR, 0, "Detroit Tigers" },
  263. { T_STR, 0, "Chicago Cubs" },
  264. end_node
  265. };
  266. struct test_node seq4[] = {
  267. { T_STR, 0, "2001-07-23" },
  268. end_node
  269. };
  270. struct test_node map[] = {
  271. { T_SEQ, 0, 0, seq3 },
  272. { T_SEQ, 0, 0, seq4 },
  273. { T_SEQ, 0, 0, seq1 },
  274. { T_SEQ, 0, 0, seq2 },
  275. end_node
  276. };
  277. struct test_node stream[] = {
  278. { T_MAP, 0, 0, map },
  279. end_node
  280. };
  281. ---
  282. test: Sequence key shortcut
  283. spec: 2.12
  284. yaml: |
  285. ---
  286. # products purchased
  287. - item : Super Hoop
  288. quantity: 1
  289. - item : Basketball
  290. quantity: 4
  291. - item : Big Shoes
  292. quantity: 1
  293. php: |
  294. array (
  295. array (
  296. 'item' => 'Super Hoop',
  297. 'quantity' => 1,
  298. ),
  299. array (
  300. 'item' => 'Basketball',
  301. 'quantity' => 4,
  302. ),
  303. array (
  304. 'item' => 'Big Shoes',
  305. 'quantity' => 1,
  306. )
  307. )
  308. perl: |
  309. [
  310. { item => 'Super Hoop', quantity => 1 },
  311. { item => 'Basketball', quantity => 4 },
  312. { item => 'Big Shoes', quantity => 1 }
  313. ]
  314. ruby: |
  315. [
  316. { 'item' => 'Super Hoop', 'quantity' => 1 },
  317. { 'item' => 'Basketball', 'quantity' => 4 },
  318. { 'item' => 'Big Shoes', 'quantity' => 1 }
  319. ]
  320. python: |
  321. [
  322. { 'item': 'Super Hoop', 'quantity': 1 },
  323. { 'item': 'Basketball', 'quantity': 4 },
  324. { 'item': 'Big Shoes', 'quantity': 1 }
  325. ]
  326. syck: |
  327. struct test_node map1[] = {
  328. { T_STR, 0, "item" },
  329. { T_STR, 0, "Super Hoop" },
  330. { T_STR, 0, "quantity" },
  331. { T_STR, 0, "1" },
  332. end_node
  333. };
  334. struct test_node map2[] = {
  335. { T_STR, 0, "item" },
  336. { T_STR, 0, "Basketball" },
  337. { T_STR, 0, "quantity" },
  338. { T_STR, 0, "4" },
  339. end_node
  340. };
  341. struct test_node map3[] = {
  342. { T_STR, 0, "item" },
  343. { T_STR, 0, "Big Shoes" },
  344. { T_STR, 0, "quantity" },
  345. { T_STR, 0, "1" },
  346. end_node
  347. };
  348. struct test_node seq[] = {
  349. { T_MAP, 0, 0, map1 },
  350. { T_MAP, 0, 0, map2 },
  351. { T_MAP, 0, 0, map3 },
  352. end_node
  353. };
  354. struct test_node stream[] = {
  355. { T_SEQ, 0, 0, seq },
  356. end_node
  357. };
  358. ---
  359. test: Literal perserves newlines
  360. todo: true
  361. spec: 2.13
  362. yaml: |
  363. # ASCII Art
  364. --- |
  365. \//||\/||
  366. // || ||_
  367. perl: |
  368. "\\//||\\/||\n// || ||_\n"
  369. ruby: |
  370. "\\//||\\/||\n// || ||_\n"
  371. python: |
  372. [
  373. flushLeft(
  374. """
  375. \//||\/||
  376. // || ||_
  377. """
  378. )
  379. ]
  380. syck: |
  381. struct test_node stream[] = {
  382. { T_STR, 0, "\\//||\\/||\n// || ||_\n" },
  383. end_node
  384. };
  385. ---
  386. test: Folded treats newlines as a space
  387. todo: true
  388. spec: 2.14
  389. yaml: |
  390. ---
  391. Mark McGwire's
  392. year was crippled
  393. by a knee injury.
  394. perl: |
  395. "Mark McGwire's year was crippled by a knee injury."
  396. ruby: |
  397. "Mark McGwire's year was crippled by a knee injury."
  398. python: |
  399. [ "Mark McGwire's year was crippled by a knee injury." ]
  400. syck: |
  401. struct test_node stream[] = {
  402. { T_STR, 0, "Mark McGwire's year was crippled by a knee injury." },
  403. end_node
  404. };
  405. ---
  406. test: Newlines preserved for indented and blank lines
  407. todo: true
  408. spec: 2.15
  409. yaml: |
  410. --- >
  411. Sammy Sosa completed another
  412. fine season with great stats.
  413. 63 Home Runs
  414. 0.288 Batting Average
  415. What a year!
  416. perl: |
  417. "Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n"
  418. ruby: |
  419. "Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n"
  420. python: |
  421. [
  422. flushLeft(
  423. """
  424. Sammy Sosa completed another fine season with great stats.
  425. 63 Home Runs
  426. 0.288 Batting Average
  427. What a year!
  428. """
  429. )
  430. ]
  431. syck: |
  432. struct test_node stream[] = {
  433. { T_STR, 0, "Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n" },
  434. end_node
  435. };
  436. ---
  437. test: Indentation determines scope
  438. spec: 2.16
  439. yaml: |
  440. name: Mark McGwire
  441. accomplishment: >
  442. Mark set a major league
  443. home run record in 1998.
  444. stats: |
  445. 65 Home Runs
  446. 0.278 Batting Average
  447. php: |
  448. array(
  449. 'name' => 'Mark McGwire',
  450. 'accomplishment' => "Mark set a major league home run record in 1998.\n",
  451. 'stats' => "65 Home Runs\n0.278 Batting Average\n"
  452. )
  453. ---
  454. test: Quoted scalars
  455. todo: true
  456. spec: 2.17
  457. yaml: |
  458. unicode: "Sosa did fine.\u263A"
  459. control: "\b1998\t1999\t2000\n"
  460. hexesc: "\x0D\x0A is \r\n"
  461. single: '"Howdy!" he cried.'
  462. quoted: ' # not a ''comment''.'
  463. tie-fighter: '|\-*-/|'
  464. ruby: |
  465. {
  466. "tie-fighter" => "|\\-*-/|",
  467. "control"=>"\0101998\t1999\t2000\n",
  468. "unicode"=>"Sosa did fine." + ["263A".hex ].pack('U*'),
  469. "quoted"=>" # not a 'comment'.",
  470. "single"=>"\"Howdy!\" he cried.",
  471. "hexesc"=>"\r\n is \r\n"
  472. }
  473. ---
  474. test: Multiline flow scalars
  475. todo: true
  476. spec: 2.18
  477. yaml: |
  478. plain:
  479. This unquoted scalar
  480. spans many lines.
  481. quoted: "So does this
  482. quoted scalar.\n"
  483. ruby: |
  484. {
  485. 'plain' => 'This unquoted scalar spans many lines.',
  486. 'quoted' => "So does this quoted scalar.\n"
  487. }
  488. ---
  489. test: Integers
  490. spec: 2.19
  491. yaml: |
  492. canonical: 12345
  493. decimal: +12,345
  494. octal: 014
  495. hexadecimal: 0xC
  496. php: |
  497. array(
  498. 'canonical' => 12345,
  499. 'decimal' => 12345,
  500. 'octal' => 014,
  501. 'hexadecimal' => 0xC
  502. )
  503. ---
  504. # FIX: spec shows parens around -inf and NaN
  505. test: Floating point
  506. spec: 2.20
  507. yaml: |
  508. canonical: 1.23015e+3
  509. exponential: 12.3015e+02
  510. fixed: 1,230.15
  511. negative infinity: -.inf
  512. not a number: .NaN
  513. float as whole number: !!float 1
  514. php: |
  515. array(
  516. 'canonical' => 1230.15,
  517. 'exponential' => 1230.15,
  518. 'fixed' => 1230.15,
  519. 'negative infinity' => log(0),
  520. 'not a number' => -log(0),
  521. 'float as whole number' => (float) 1
  522. )
  523. ---
  524. test: Miscellaneous
  525. spec: 2.21
  526. yaml: |
  527. null: ~
  528. true: true
  529. false: false
  530. string: '12345'
  531. php: |
  532. array(
  533. '' => null,
  534. 1 => true,
  535. 0 => false,
  536. 'string' => '12345'
  537. )
  538. ---
  539. test: Timestamps
  540. todo: true
  541. spec: 2.22
  542. yaml: |
  543. canonical: 2001-12-15T02:59:43.1Z
  544. iso8601: 2001-12-14t21:59:43.10-05:00
  545. spaced: 2001-12-14 21:59:43.10 -05:00
  546. date: 2002-12-14 # Time is noon UTC
  547. php: |
  548. array(
  549. 'canonical' => YAML::mktime( 2001, 12, 15, 2, 59, 43, 0.10 ),
  550. 'iso8601' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
  551. 'spaced' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
  552. 'date' => Date.new( 2002, 12, 14 )
  553. )
  554. ---
  555. test: legacy Timestamps test
  556. todo: true
  557. spec: legacy D4
  558. yaml: |
  559. canonical: 2001-12-15T02:59:43.00Z
  560. iso8601: 2001-02-28t21:59:43.00-05:00
  561. spaced: 2001-12-14 21:59:43.00 -05:00
  562. date: 2002-12-14
  563. php: |
  564. array(
  565. 'canonical' => Time::utc( 2001, 12, 15, 2, 59, 43, 0 ),
  566. 'iso8601' => YAML::mktime( 2001, 2, 28, 21, 59, 43, 0, "-05:00" ),
  567. 'spaced' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0, "-05:00" ),
  568. 'date' => Date.new( 2002, 12, 14 )
  569. )
  570. ---
  571. test: Various explicit families
  572. todo: true
  573. spec: 2.23
  574. yaml: |
  575. not-date: !str 2002-04-28
  576. picture: !binary |
  577. R0lGODlhDAAMAIQAAP//9/X
  578. 17unp5WZmZgAAAOfn515eXv
  579. Pz7Y6OjuDg4J+fn5OTk6enp
  580. 56enmleECcgggoBADs=
  581. application specific tag: !!something |
  582. The semantics of the tag
  583. above may be different for
  584. different documents.
  585. ruby-setup: |
  586. YAML.add_private_type( "something" ) do |type, val|
  587. "SOMETHING: #{val}"
  588. end
  589. ruby: |
  590. {
  591. 'not-date' => '2002-04-28',
  592. 'picture' => "GIF89a\f\000\f\000\204\000\000\377\377\367\365\365\356\351\351\345fff\000\000\000\347\347\347^^^\363\363\355\216\216\216\340\340\340\237\237\237\223\223\223\247\247\247\236\236\236i^\020' \202\n\001\000;",
  593. 'application specific tag' => "SOMETHING: The semantics of the tag\nabove may be different for\ndifferent documents.\n"
  594. }
  595. ---
  596. test: Application specific family
  597. todo: true
  598. spec: 2.24
  599. yaml: |
  600. # Establish a tag prefix
  601. --- !clarkevans.com,2002/graph/^shape
  602. # Use the prefix: shorthand for
  603. # !clarkevans.com,2002/graph/circle
  604. - !^circle
  605. center: &ORIGIN {x: 73, 'y': 129}
  606. radius: 7
  607. - !^line # !clarkevans.com,2002/graph/line
  608. start: *ORIGIN
  609. finish: { x: 89, 'y': 102 }
  610. - !^label
  611. start: *ORIGIN
  612. color: 0xFFEEBB
  613. value: Pretty vector drawing.
  614. ruby-setup: |
  615. YAML.add_domain_type( "clarkevans.com,2002", 'graph/shape' ) { |type, val|
  616. if Array === val
  617. val << "Shape Container"
  618. val
  619. else
  620. raise YAML::Error, "Invalid graph of class #{ val.class }: " + val.inspect
  621. end
  622. }
  623. one_shape_proc = Proc.new { |type, val|
  624. scheme, domain, type = type.split( /:/, 3 )
  625. if val.is_a? ::Hash
  626. val['TYPE'] = "Shape: #{type}"
  627. val
  628. else
  629. raise YAML::Error, "Invalid graph of class #{ val.class }: " + val.inspect
  630. end
  631. }
  632. YAML.add_domain_type( "clarkevans.com,2002", 'graph/circle', &one_shape_proc )
  633. YAML.add_domain_type( "clarkevans.com,2002", 'graph/line', &one_shape_proc )
  634. YAML.add_domain_type( "clarkevans.com,2002", 'graph/label', &one_shape_proc )
  635. ruby: |
  636. [
  637. {
  638. "radius" => 7,
  639. "center"=>
  640. {
  641. "x" => 73,
  642. "y" => 129
  643. },
  644. "TYPE" => "Shape: graph/circle"
  645. }, {
  646. "finish" =>
  647. {
  648. "x" => 89,
  649. "y" => 102
  650. },
  651. "TYPE" => "Shape: graph/line",
  652. "start" =>
  653. {
  654. "x" => 73,
  655. "y" => 129
  656. }
  657. }, {
  658. "TYPE" => "Shape: graph/label",
  659. "value" => "Pretty vector drawing.",
  660. "start" =>
  661. {
  662. "x" => 73,
  663. "y" => 129
  664. },
  665. "color" => 16772795
  666. },
  667. "Shape Container"
  668. ]
  669. # ---
  670. # test: Unordered set
  671. # spec: 2.25
  672. # yaml: |
  673. # # sets are represented as a
  674. # # mapping where each key is
  675. # # associated with the empty string
  676. # --- !set
  677. # ? Mark McGwire
  678. # ? Sammy Sosa
  679. # ? Ken Griff
  680. ---
  681. test: Ordered mappings
  682. todo: true
  683. spec: 2.26
  684. yaml: |
  685. # ordered maps are represented as
  686. # a sequence of mappings, with
  687. # each mapping having one key
  688. --- !omap
  689. - Mark McGwire: 65
  690. - Sammy Sosa: 63
  691. - Ken Griffy: 58
  692. ruby: |
  693. YAML::Omap[
  694. 'Mark McGwire', 65,
  695. 'Sammy Sosa', 63,
  696. 'Ken Griffy', 58
  697. ]
  698. ---
  699. test: Invoice
  700. dump_skip: true
  701. spec: 2.27
  702. yaml: |
  703. --- !clarkevans.com,2002/^invoice
  704. invoice: 34843
  705. date : 2001-01-23
  706. bill-to: &id001
  707. given : Chris
  708. family : Dumars
  709. address:
  710. lines: |
  711. 458 Walkman Dr.
  712. Suite #292
  713. city : Royal Oak
  714. state : MI
  715. postal : 48046
  716. ship-to: *id001
  717. product:
  718. -
  719. sku : BL394D
  720. quantity : 4
  721. description : Basketball
  722. price : 450.00
  723. -
  724. sku : BL4438H
  725. quantity : 1
  726. description : Super Hoop
  727. price : 2392.00
  728. tax : 251.42
  729. total: 4443.52
  730. comments: >
  731. Late afternoon is best.
  732. Backup contact is Nancy
  733. Billsmer @ 338-4338.
  734. php: |
  735. array(
  736. 'invoice' => 34843, 'date' => mktime(0, 0, 0, 1, 23, 2001),
  737. 'bill-to' =>
  738. array( 'given' => 'Chris', 'family' => 'Dumars', 'address' => array( 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ) )
  739. , 'ship-to' =>
  740. array( 'given' => 'Chris', 'family' => 'Dumars', 'address' => array( 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ) )
  741. , 'product' =>
  742. array(
  743. array( 'sku' => 'BL394D', 'quantity' => 4, 'description' => 'Basketball', 'price' => 450.00 ),
  744. array( 'sku' => 'BL4438H', 'quantity' => 1, 'description' => 'Super Hoop', 'price' => 2392.00 )
  745. ),
  746. 'tax' => 251.42, 'total' => 4443.52,
  747. 'comments' => "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.\n"
  748. )
  749. ---
  750. test: Log file
  751. todo: true
  752. spec: 2.28
  753. yaml: |
  754. ---
  755. Time: 2001-11-23 15:01:42 -05:00
  756. User: ed
  757. Warning: >
  758. This is an error message
  759. for the log file
  760. ---
  761. Time: 2001-11-23 15:02:31 -05:00
  762. User: ed
  763. Warning: >
  764. A slightly different error
  765. message.
  766. ---
  767. Date: 2001-11-23 15:03:17 -05:00
  768. User: ed
  769. Fatal: >
  770. Unknown variable "bar"
  771. Stack:
  772. - file: TopClass.py
  773. line: 23
  774. code: |
  775. x = MoreObject("345\n")
  776. - file: MoreClass.py
  777. line: 58
  778. code: |-
  779. foo = bar
  780. ruby: |
  781. y = YAML::Stream.new
  782. y.add( { 'Time' => YAML::mktime( 2001, 11, 23, 15, 01, 42, 00, "-05:00" ),
  783. 'User' => 'ed', 'Warning' => "This is an error message for the log file\n" } )
  784. y.add( { 'Time' => YAML::mktime( 2001, 11, 23, 15, 02, 31, 00, "-05:00" ),
  785. 'User' => 'ed', 'Warning' => "A slightly different error message.\n" } )
  786. y.add( { 'Date' => YAML::mktime( 2001, 11, 23, 15, 03, 17, 00, "-05:00" ),
  787. 'User' => 'ed', 'Fatal' => "Unknown variable \"bar\"\n",
  788. 'Stack' => [
  789. { 'file' => 'TopClass.py', 'line' => 23, 'code' => "x = MoreObject(\"345\\n\")\n" },
  790. { 'file' => 'MoreClass.py', 'line' => 58, 'code' => "foo = bar" } ] } )
  791. documents: 3
  792. ---
  793. test: Throwaway comments
  794. yaml: |
  795. ### These are four throwaway comment ###
  796. ### lines (the second line is empty). ###
  797. this: | # Comments may trail lines.
  798. contains three lines of text.
  799. The third one starts with a
  800. # character. This isn't a comment.
  801. # These are three throwaway comment
  802. # lines (the first line is empty).
  803. php: |
  804. array(
  805. 'this' => "contains three lines of text.\nThe third one starts with a\n# character. This isn't a comment.\n"
  806. )
  807. ---
  808. test: Document with a single value
  809. todo: true
  810. yaml: |
  811. --- >
  812. This YAML stream contains a single text value.
  813. The next stream is a log file - a sequence of
  814. log entries. Adding an entry to the log is a
  815. simple matter of appending it at the end.
  816. ruby: |
  817. "This YAML stream contains a single text value. The next stream is a log file - a sequence of log entries. Adding an entry to the log is a simple matter of appending it at the end.\n"
  818. ---
  819. test: Document stream
  820. todo: true
  821. yaml: |
  822. ---
  823. at: 2001-08-12 09:25:00.00 Z
  824. type: GET
  825. HTTP: '1.0'
  826. url: '/index.html'
  827. ---
  828. at: 2001-08-12 09:25:10.00 Z
  829. type: GET
  830. HTTP: '1.0'
  831. url: '/toc.html'
  832. ruby: |
  833. y = YAML::Stream.new
  834. y.add( {
  835. 'at' => Time::utc( 2001, 8, 12, 9, 25, 00 ),
  836. 'type' => 'GET',
  837. 'HTTP' => '1.0',
  838. 'url' => '/index.html'
  839. } )
  840. y.add( {
  841. 'at' => Time::utc( 2001, 8, 12, 9, 25, 10 ),
  842. 'type' => 'GET',
  843. 'HTTP' => '1.0',
  844. 'url' => '/toc.html'
  845. } )
  846. documents: 2
  847. ---
  848. test: Top level mapping
  849. yaml: |
  850. # This stream is an example of a top-level mapping.
  851. invoice : 34843
  852. date : 2001-01-23
  853. total : 4443.52
  854. php: |
  855. array(
  856. 'invoice' => 34843,
  857. 'date' => mktime(0, 0, 0, 1, 23, 2001),
  858. 'total' => 4443.52
  859. )
  860. ---
  861. test: Single-line documents
  862. todo: true
  863. yaml: |
  864. # The following is a sequence of three documents.
  865. # The first contains an empty mapping, the second
  866. # an empty sequence, and the last an empty string.
  867. --- {}
  868. --- [ ]
  869. --- ''
  870. ruby: |
  871. y = YAML::Stream.new
  872. y.add( {} )
  873. y.add( [] )
  874. y.add( '' )
  875. documents: 3
  876. ---
  877. test: Document with pause
  878. todo: true
  879. yaml: |
  880. # A communication channel based on a YAML stream.
  881. ---
  882. sent at: 2002-06-06 11:46:25.10 Z
  883. payload: Whatever
  884. # Receiver can process this as soon as the following is sent:
  885. ...
  886. # Even if the next message is sent long after:
  887. ---
  888. sent at: 2002-06-06 12:05:53.47 Z
  889. payload: Whatever
  890. ...
  891. ruby: |
  892. y = YAML::Stream.new
  893. y.add(
  894. { 'sent at' => YAML::mktime( 2002, 6, 6, 11, 46, 25, 0.10 ),
  895. 'payload' => 'Whatever' }
  896. )
  897. y.add(
  898. { "payload" => "Whatever", "sent at" => YAML::mktime( 2002, 6, 6, 12, 5, 53, 0.47 ) }
  899. )
  900. documents: 2
  901. ---
  902. test: Explicit typing
  903. yaml: |
  904. integer: 12
  905. also int: ! "12"
  906. string: !str 12
  907. php: |
  908. array( 'integer' => 12, 'also int' => 12, 'string' => '12' )
  909. ---
  910. test: Private types
  911. todo: true
  912. yaml: |
  913. # Both examples below make use of the 'x-private:ball'
  914. # type family URI, but with different semantics.
  915. ---
  916. pool: !!ball
  917. number: 8
  918. color: black
  919. ---
  920. bearing: !!ball
  921. material: steel
  922. ruby: |
  923. y = YAML::Stream.new
  924. y.add( { 'pool' =>
  925. YAML::PrivateType.new( 'ball',
  926. { 'number' => 8, 'color' => 'black' } ) }
  927. )
  928. y.add( { 'bearing' =>
  929. YAML::PrivateType.new( 'ball',
  930. { 'material' => 'steel' } ) }
  931. )
  932. documents: 2
  933. ---
  934. test: Type family under yaml.org
  935. yaml: |
  936. # The URI is 'tag:yaml.org,2002:str'
  937. - !str a Unicode string
  938. php: |
  939. array( 'a Unicode string' )
  940. ---
  941. test: Type family under perl.yaml.org
  942. todo: true
  943. yaml: |
  944. # The URI is 'tag:perl.yaml.org,2002:Text::Tabs'
  945. - !perl/Text::Tabs {}
  946. ruby: |
  947. [ YAML::DomainType.new( 'perl.yaml.org,2002', 'Text::Tabs', {} ) ]
  948. ---
  949. test: Type family under clarkevans.com
  950. todo: true
  951. yaml: |
  952. # The URI is 'tag:clarkevans.com,2003-02:timesheet'
  953. - !clarkevans.com,2003-02/timesheet {}
  954. ruby: |
  955. [ YAML::DomainType.new( 'clarkevans.com,2003-02', 'timesheet', {} ) ]
  956. ---
  957. test: URI Escaping
  958. todo: true
  959. yaml: |
  960. same:
  961. - !domain.tld,2002/type\x30 value
  962. - !domain.tld,2002/type0 value
  963. different: # As far as the YAML parser is concerned
  964. - !domain.tld,2002/type%30 value
  965. - !domain.tld,2002/type0 value
  966. ruby-setup: |
  967. YAML.add_domain_type( "domain.tld,2002", "type0" ) { |type, val|
  968. "ONE: #{val}"
  969. }
  970. YAML.add_domain_type( "domain.tld,2002", "type%30" ) { |type, val|
  971. "TWO: #{val}"
  972. }
  973. ruby: |
  974. { 'same' => [ 'ONE: value', 'ONE: value' ], 'different' => [ 'TWO: value', 'ONE: value' ] }
  975. ---
  976. test: URI Prefixing
  977. todo: true
  978. yaml: |
  979. # 'tag:domain.tld,2002:invoice' is some type family.
  980. invoice: !domain.tld,2002/^invoice
  981. # 'seq' is shorthand for 'tag:yaml.org,2002:seq'.
  982. # This does not effect '^customer' below
  983. # because it is does not specify a prefix.
  984. customers: !seq
  985. # '^customer' is shorthand for the full
  986. # notation 'tag:domain.tld,2002:customer'.
  987. - !^customer
  988. given : Chris
  989. family : Dumars
  990. ruby-setup: |
  991. YAML.add_domain_type( "domain.tld,2002", /(invoice|customer)/ ) { |type, val|
  992. if val.is_a? ::Hash
  993. scheme, domain, type = type.split( /:/, 3 )
  994. val['type'] = "domain #{type}"
  995. val
  996. else
  997. raise YAML::Error, "Not a Hash in domain.tld/invoice: " + val.inspect
  998. end
  999. }
  1000. ruby: |
  1001. { "invoice"=> { "customers"=> [ { "given"=>"Chris", "type"=>"domain customer", "family"=>"Dumars" } ], "type"=>"domain invoice" } }
  1002. ---
  1003. test: Overriding anchors
  1004. yaml: |
  1005. anchor : &A001 This scalar has an anchor.
  1006. override : &A001 >
  1007. The alias node below is a
  1008. repeated use of this value.
  1009. alias : *A001
  1010. php: |
  1011. array( 'anchor' => 'This scalar has an anchor.',
  1012. 'override' => "The alias node below is a repeated use of this value.\n",
  1013. 'alias' => "The alias node below is a repeated use of this value.\n" )
  1014. ---
  1015. test: Flow and block formatting
  1016. todo: true
  1017. yaml: |
  1018. empty: []
  1019. flow: [ one, two, three # May span lines,
  1020. , four, # indentation is
  1021. five ] # mostly ignored.
  1022. block:
  1023. - First item in top sequence
  1024. -
  1025. - Subordinate sequence entry
  1026. - >
  1027. A folded sequence entry
  1028. - Sixth item in top sequence
  1029. ruby: |
  1030. { 'empty' => [], 'flow' => [ 'one', 'two', 'three', 'four', 'five' ],
  1031. 'block' => [ 'First item in top sequence', [ 'Subordinate sequence entry' ],
  1032. "A folded sequence entry\n", 'Sixth item in top sequence' ] }
  1033. ---
  1034. test: Complete mapping test
  1035. todo: true
  1036. yaml: |
  1037. empty: {}
  1038. flow: { one: 1, two: 2 }
  1039. spanning: { one: 1,
  1040. two: 2 }
  1041. block:
  1042. first : First entry
  1043. second:
  1044. key: Subordinate mapping
  1045. third:
  1046. - Subordinate sequence
  1047. - { }
  1048. - Previous mapping is empty.
  1049. - A key: value pair in a sequence.
  1050. A second: key:value pair.
  1051. - The previous entry is equal to the following one.
  1052. -
  1053. A key: value pair in a sequence.
  1054. A second: key:value pair.
  1055. !float 12 : This key is a float.
  1056. ? >
  1057. ?
  1058. : This key had to be protected.
  1059. "\a" : This key had to be escaped.
  1060. ? >
  1061. This is a
  1062. multi-line
  1063. folded key
  1064. : Whose value is
  1065. also multi-line.
  1066. ? this also works as a key
  1067. : with a value at the next line.
  1068. ?
  1069. - This key
  1070. - is a sequence
  1071. :
  1072. - With a sequence value.
  1073. ?
  1074. This: key
  1075. is a: mapping
  1076. :
  1077. with a: mapping value.
  1078. ruby: |
  1079. { 'empty' => {}, 'flow' => { 'one' => 1, 'two' => 2 },
  1080. 'spanning' => { 'one' => 1, 'two' => 2 },
  1081. 'block' => { 'first' => 'First entry', 'second' =>
  1082. { 'key' => 'Subordinate mapping' }, 'third' =>
  1083. [ 'Subordinate sequence', {}, 'Previous mapping is empty.',
  1084. { 'A key' => 'value pair in a sequence.', 'A second' => 'key:value pair.' },
  1085. 'The previous entry is equal to the following one.',
  1086. { 'A key' => 'value pair in a sequence.', 'A second' => 'key:value pair.' } ],
  1087. 12.0 => 'This key is a float.', "?\n" => 'This key had to be protected.',
  1088. "\a" => 'This key had to be escaped.',
  1089. "This is a multi-line folded key\n" => "Whose value is also multi-line.",
  1090. 'this also works as a key' => 'with a value at the next line.',
  1091. [ 'This key', 'is a sequence' ] => [ 'With a sequence value.' ] } }
  1092. # Couldn't recreate map exactly, so we'll do a detailed check to be sure it's entact
  1093. obj_y['block'].keys.each { |k|
  1094. if Hash === k
  1095. v = obj_y['block'][k]
  1096. if k['This'] == 'key' and k['is a'] == 'mapping' and v['with a'] == 'mapping value.'
  1097. obj_r['block'][k] = v
  1098. end
  1099. end
  1100. }
  1101. ---
  1102. test: Literal explicit indentation
  1103. yaml: |
  1104. # Explicit indentation must
  1105. # be given in all the three
  1106. # following cases.
  1107. leading spaces: |2
  1108. This value starts with four spaces.
  1109. leading line break: |2
  1110. This value starts with a line break.
  1111. leading comment indicator: |2
  1112. # first line starts with a
  1113. # character.
  1114. # Explicit indentation may
  1115. # also be given when it is
  1116. # not required.
  1117. redundant: |2
  1118. This value is indented 2 spaces.
  1119. php: |
  1120. array(
  1121. 'leading spaces' => " This value starts with four spaces.\n",
  1122. 'leading line break' => "\nThis value starts with a line break.\n",
  1123. 'leading comment indicator' => "# first line starts with a\n# character.\n",
  1124. 'redundant' => "This value is indented 2 spaces.\n"
  1125. )
  1126. ---
  1127. test: Chomping and keep modifiers
  1128. yaml: |
  1129. clipped: |
  1130. This has one newline.
  1131. same as "clipped" above: "This has one newline.\n"
  1132. stripped: |-
  1133. This has no newline.
  1134. same as "stripped" above: "This has no newline."
  1135. kept: |+
  1136. This has two newlines.
  1137. same as "kept" above: "This has two newlines.\n\n"
  1138. php: |
  1139. array(
  1140. 'clipped' => "This has one newline.\n",
  1141. 'same as "clipped" above' => "This has one newline.\n",
  1142. 'stripped' => 'This has no newline.',
  1143. 'same as "stripped" above' => 'This has no newline.',
  1144. 'kept' => "This has two newlines.\n\n",
  1145. 'same as "kept" above' => "This has two newlines.\n\n"
  1146. )
  1147. ---
  1148. test: Literal combinations
  1149. todo: true
  1150. yaml: |
  1151. empty: |
  1152. literal: |
  1153. The \ ' " characters may be
  1154. freely used. Leading white
  1155. space is significant.
  1156. Line breaks are significant.
  1157. Thus this value contains one
  1158. empty line and ends with a
  1159. single line break, but does
  1160. not start with one.
  1161. is equal to: "The \\ ' \" characters may \
  1162. be\nfreely used. Leading white\n space \
  1163. is significant.\n\nLine breaks are \
  1164. significant.\nThus this value contains \
  1165. one\nempty line and ends with a\nsingle \
  1166. line break, but does\nnot start with one.\n"
  1167. # Comments may follow a block
  1168. # scalar value. They must be
  1169. # less indented.
  1170. # Modifiers may be combined in any order.
  1171. indented and chomped: |2-
  1172. This has no newline.
  1173. also written as: |-2
  1174. This has no newline.
  1175. both are equal to: " This has no newline."
  1176. php: |
  1177. array(
  1178. 'empty' => '',
  1179. 'literal' => "The \\ ' \" characters may be\nfreely used. Leading white\n space " +
  1180. "is significant.\n\nLine breaks are significant.\nThus this value contains one\n" +
  1181. "empty line and ends with a\nsingle line break, but does\nnot start with one.\n",
  1182. 'is equal to' => "The \\ ' \" characters may be\nfreely used. Leading white\n space " +
  1183. "is significant.\n\nLine breaks are significant.\nThus this value contains one\n" +
  1184. "empty line and ends with a\nsingle line break, but does\nnot start with one.\n",
  1185. 'indented and chomped' => ' This has no newline.',
  1186. 'also written as' => ' This has no newline.',
  1187. 'both are equal to' => ' This has no newline.'
  1188. )
  1189. ---
  1190. test: Folded combinations
  1191. todo: true
  1192. yaml: |
  1193. empty: >
  1194. one paragraph: >
  1195. Line feeds are converted
  1196. to spaces, so this value
  1197. contains no line breaks
  1198. except for the final one.
  1199. multiple paragraphs: >2
  1200. An empty line, either
  1201. at the start or in
  1202. the value:
  1203. Is interpreted as a
  1204. line break. Thus this
  1205. value contains three
  1206. line breaks.
  1207. indented text: >
  1208. This is a folded
  1209. paragraph followed
  1210. by a list:
  1211. * first entry
  1212. * second entry
  1213. Followed by another
  1214. folded paragraph,
  1215. another list:
  1216. * first entry
  1217. * second entry
  1218. And a final folded
  1219. paragraph.
  1220. above is equal to: |
  1221. This is a folded paragraph followed by a list:
  1222. * first entry
  1223. * second entry
  1224. Followed by another folded paragraph, another list:
  1225. * first entry
  1226. * second entry
  1227. And a final folded paragraph.
  1228. # Explicit comments may follow
  1229. # but must be less indented.
  1230. php: |
  1231. array(
  1232. 'empty' => '',
  1233. 'one paragraph' => 'Line feeds are converted to spaces, so this value'.
  1234. " contains no line breaks except for the final one.\n",
  1235. 'multiple paragraphs' => "\nAn empty line, either at the start or in the value:\n".
  1236. "Is interpreted as a line break. Thus this value contains three line breaks.\n",
  1237. 'indented text' => "This is a folded paragraph followed by a list:\n".
  1238. " * first entry\n * second entry\nFollowed by another folded paragraph, ".
  1239. "another list:\n\n * first entry\n\n * second entry\n\nAnd a final folded paragraph.\n",
  1240. 'above is equal to' => "This is a folded paragraph followed by a list:\n".
  1241. " * first entry\n * second entry\nFollowed by another folded paragraph, ".
  1242. "another list:\n\n * first entry\n\n * second entry\n\nAnd a final folded paragraph.\n"
  1243. )
  1244. ---
  1245. test: Single quotes
  1246. todo: true
  1247. yaml: |
  1248. empty: ''
  1249. second: '! : \ etc. can be used freely.'
  1250. third: 'a single quote '' must be escaped.'
  1251. span: 'this contains
  1252. six spaces
  1253. and one
  1254. line break'
  1255. is same as: "this contains six spaces\nand one line break"
  1256. php: |
  1257. array(
  1258. 'empty' => '',
  1259. 'second' => '! : \\ etc. can be used freely.',
  1260. 'third' => "a single quote ' must be escaped.",
  1261. 'span' => "this contains six spaces\nand one line break",
  1262. 'is same as' => "this contains six spaces\nand one line break"
  1263. )
  1264. ---
  1265. test: Double quotes
  1266. todo: true
  1267. yaml: |
  1268. empty: ""
  1269. second: "! : etc. can be used freely."
  1270. third: "a \" or a \\ must be escaped."
  1271. fourth: "this value ends with an LF.\n"
  1272. span: "this contains
  1273. four \
  1274. spaces"
  1275. is equal to: "this contains four spaces"
  1276. php: |
  1277. array(
  1278. 'empty' => '',
  1279. 'second' => '! : etc. can be used freely.',
  1280. 'third' => 'a " or a \\ must be escaped.',
  1281. 'fourth' => "this value ends with an LF.\n",
  1282. 'span' => "this contains four spaces",
  1283. 'is equal to' => "this contains four spaces"
  1284. )
  1285. ---
  1286. test: Unquoted strings
  1287. todo: true
  1288. yaml: |
  1289. first: There is no unquoted empty string.
  1290. second: 12 ## This is an integer.
  1291. third: !str 12 ## This is a string.
  1292. span: this contains
  1293. six spaces
  1294. and one
  1295. line break
  1296. indicators: this has no comments.
  1297. #:foo and bar# are
  1298. both text.
  1299. flow: [ can span
  1300. lines, # comment
  1301. like
  1302. this ]
  1303. note: { one-line keys: but multi-line values }
  1304. php: |
  1305. array(
  1306. 'first' => 'There is no unquoted empty string.',
  1307. 'second' => 12,
  1308. 'third' => '12',
  1309. 'span' => "this contains six spaces\nand one line break",
  1310. 'indicators' => "this has no comments. #:foo and bar# are both text.",
  1311. 'flow' => [ 'can span lines', 'like this' ],
  1312. 'note' => { 'one-line keys' => 'but multi-line values' }
  1313. )
  1314. ---
  1315. test: Spanning sequences
  1316. todo: true
  1317. yaml: |
  1318. # The following are equal seqs
  1319. # with different identities.
  1320. flow: [ one, two ]
  1321. spanning: [ one,
  1322. two ]
  1323. block:
  1324. - one
  1325. - two
  1326. php: |
  1327. array(
  1328. 'flow' => [ 'one', 'two' ],
  1329. 'spanning' => [ 'one', 'two' ],
  1330. 'block' => [ 'one', 'two' ]
  1331. )
  1332. ---
  1333. test: Flow mappings
  1334. yaml: |
  1335. # The following are equal maps
  1336. # with different identities.
  1337. flow: { one: 1, two: 2 }
  1338. block:
  1339. one: 1
  1340. two: 2
  1341. php: |
  1342. array(
  1343. 'flow' => array( 'one' => 1, 'two' => 2 ),
  1344. 'block' => array( 'one' => 1, 'two' => 2 )
  1345. )
  1346. ---
  1347. test: Representations of 12
  1348. todo: true
  1349. yaml: |
  1350. - 12 # An integer
  1351. # The following scalars
  1352. # are loaded to the
  1353. # string value '1' '2'.
  1354. - !str 12
  1355. - '12'
  1356. - "12"
  1357. - "\
  1358. 1\
  1359. 2\
  1360. "
  1361. # Strings containing paths and regexps can be unquoted:
  1362. - /foo/bar
  1363. - d:/foo/bar
  1364. - foo/bar
  1365. - /a.*b/
  1366. php: |
  1367. array( 12, '12', '12', '12', '12', '/foo/bar', 'd:/foo/bar', 'foo/bar', '/a.*b/' )
  1368. ---
  1369. test: "Null"
  1370. todo: true
  1371. yaml: |
  1372. canonical: ~
  1373. english: null
  1374. # This sequence has five
  1375. # entries, two with values.
  1376. sparse:
  1377. - ~
  1378. - 2nd entry
  1379. - Null
  1380. - 4th entry
  1381. -
  1382. four: This mapping has five keys,
  1383. only two with values.
  1384. php: |
  1385. array (
  1386. 'canonical' => null,
  1387. 'english' => null,
  1388. 'sparse' => array( null, '2nd entry', null, '4th entry', null ]),
  1389. 'four' => 'This mapping has five keys, only two with values.'
  1390. )
  1391. ---
  1392. test: Omap
  1393. todo: true
  1394. yaml: |
  1395. # Explicitly typed dictionary.
  1396. Bestiary: !omap
  1397. - aardvark: African pig-like ant eater. Ugly.
  1398. - anteater: South-American ant eater. Two species.
  1399. - anaconda: South-American constrictor snake. Scary.
  1400. # Etc.
  1401. ruby: |
  1402. {
  1403. 'Bestiary' => YAML::Omap[
  1404. 'aardvark', 'African pig-like ant eater. Ugly.',
  1405. 'anteater', 'South-American ant eater. Two species.',
  1406. 'anaconda', 'South-American constrictor snake. Scary.'
  1407. ]
  1408. }
  1409. ---
  1410. test: Pairs
  1411. todo: true
  1412. yaml: |
  1413. # Explicitly typed pairs.
  1414. tasks: !pairs
  1415. - meeting: with team.
  1416. - meeting: with boss.
  1417. - break: lunch.
  1418. - meeting: with client.
  1419. ruby: |
  1420. {
  1421. 'tasks' => YAML::Pairs[
  1422. 'meeting', 'with team.',
  1423. 'meeting', 'with boss.',
  1424. 'break', 'lunch.',
  1425. 'meeting', 'with client.'
  1426. ]
  1427. }
  1428. ---
  1429. test: Set
  1430. todo: true
  1431. yaml: |
  1432. # Explicitly typed set.
  1433. baseball players: !set
  1434. Mark McGwire:
  1435. Sammy Sosa:
  1436. Ken Griffey:
  1437. ruby: |
  1438. {
  1439. 'baseball players' => YAML::Set[
  1440. 'Mark McGwire', nil,
  1441. 'Sammy Sosa', nil,
  1442. 'Ken Griffey', nil
  1443. ]
  1444. }
  1445. ---
  1446. test: Boolean
  1447. yaml: |
  1448. false: used as key
  1449. logical: true
  1450. answer: false
  1451. php: |
  1452. array(
  1453. false => 'used as key',
  1454. 'logical' => true,
  1455. 'answer' => false
  1456. )
  1457. ---
  1458. test: Integer
  1459. yaml: |
  1460. canonical: 12345
  1461. decimal: +12,345
  1462. octal: 014
  1463. hexadecimal: 0xC
  1464. php: |
  1465. array(
  1466. 'canonical' => 12345,
  1467. 'decimal' => 12345,
  1468. 'octal' => 12,
  1469. 'hexadecimal' => 12
  1470. )
  1471. ---
  1472. test: Float
  1473. yaml: |
  1474. canonical: 1.23015e+3
  1475. exponential: 12.3015e+02
  1476. fixed: 1,230.15
  1477. negative infinity: -.inf
  1478. not a number: .NaN
  1479. php: |
  1480. array(
  1481. 'canonical' => 1230.15,
  1482. 'exponential' => 1230.15,
  1483. 'fixed' => 1230.15,
  1484. 'negative infinity' => log(0),
  1485. 'not a number' => -log(0)
  1486. )
  1487. ---
  1488. test: Timestamp
  1489. todo: true
  1490. yaml: |
  1491. canonical: 2001-12-15T02:59:43.1Z
  1492. valid iso8601: 2001-12-14t21:59:43.10-05:00
  1493. space separated: 2001-12-14 21:59:43.10 -05:00
  1494. date (noon UTC): 2002-12-14
  1495. ruby: |
  1496. array(
  1497. 'canonical' => YAML::mktime( 2001, 12, 15, 2, 59, 43, 0.10 ),
  1498. 'valid iso8601' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
  1499. 'space separated' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
  1500. 'date (noon UTC)' => Date.new( 2002, 12, 14 )
  1501. )
  1502. ---
  1503. test: Binary
  1504. todo: true
  1505. yaml: |
  1506. canonical: !binary "\
  1507. R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5\
  1508. OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+\
  1509. +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC\
  1510. AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs="
  1511. base64: !binary |
  1512. R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5
  1513. OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+
  1514. +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC
  1515. AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=
  1516. description: >
  1517. The binary value above is a tiny arrow
  1518. encoded as a gif image.
  1519. ruby-setup: |
  1520. arrow_gif = "GIF89a\f\000\f\000\204\000\000\377\377\367\365\365\356\351\351\345fff\000\000\000\347\347\347^^^\363\363\355\216\216\216\340\340\340\237\237\237\223\223\223\247\247\247\236\236\236iiiccc\243\243\243\204\204\204\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371!\376\016Made with GIMP\000,\000\000\000\000\f\000\f\000\000\005, \216\2010\236\343@\024\350i\020\304\321\212\010\034\317\200M$z\357\3770\205p\270\2601f\r\e\316\001\303\001\036\020' \202\n\001\000;"
  1521. ruby: |
  1522. {
  1523. 'canonical' => arrow_gif,
  1524. 'base64' => arrow_gif,
  1525. 'description' => "The binary value above is a tiny arrow encoded as a gif image.\n"
  1526. }
  1527. ---
  1528. test: Merge key
  1529. todo: true
  1530. yaml: |
  1531. ---
  1532. - &CENTER { x: 1, y: 2 }
  1533. - &LEFT { x: 0, y: 2 }
  1534. - &BIG { r: 10 }
  1535. - &SMALL { r: 1 }
  1536. # All the following maps are equal:
  1537. - # Explicit keys
  1538. x: 1
  1539. y: 2
  1540. r: 10
  1541. label: center/big
  1542. - # Merge one map
  1543. << : *CENTER
  1544. r: 10
  1545. label: center/big
  1546. - # Merge multiple maps
  1547. << : [ *CENTER, *BIG ]
  1548. label: center/big
  1549. - # Override
  1550. << : [ *BIG, *LEFT, *SMALL ]
  1551. x: 1
  1552. label: center/big
  1553. ruby-setup: |
  1554. center = { 'x' => 1, 'y' => 2 }
  1555. left = { 'x' => 0, 'y' => 2 }
  1556. big = { 'r' => 10 }
  1557. small = { 'r' => 1 }
  1558. node1 = { 'x' => 1, 'y' => 2, 'r' => 10, 'label' => 'center/big' }
  1559. node2 = center.dup
  1560. node2.update( { 'r' => 10, 'label' => 'center/big' } )
  1561. node3 = big.dup
  1562. node3.update( center )
  1563. node3.update( { 'label' => 'center/big' } )
  1564. node4 = small.dup
  1565. node4.update( left )
  1566. node4.update( big )
  1567. node4.update( { 'x' => 1, 'label' => 'center/big' } )
  1568. ruby: |
  1569. [
  1570. center, left, big, small, node1, node2, node3, node4
  1571. ]
  1572. ---
  1573. test: Default key
  1574. todo: true
  1575. yaml: |
  1576. --- # Old schema
  1577. link with:
  1578. - library1.dll
  1579. - library2.dll
  1580. --- # New schema
  1581. link with:
  1582. - = : library1.dll
  1583. version: 1.2
  1584. - = : library2.dll
  1585. version: 2.3
  1586. ruby: |
  1587. y = YAML::Stream.new
  1588. y.add( { 'link with' => [ 'library1.dll', 'library2.dll' ] } )
  1589. obj_h = Hash[ 'version' => 1.2 ]
  1590. obj_h.default = 'library1.dll'
  1591. obj_h2 = Hash[ 'version' => 2.3 ]
  1592. obj_h2.default = 'library2.dll'
  1593. y.add( { 'link with' => [ obj_h, obj_h2 ] } )
  1594. documents: 2
  1595. ---
  1596. test: Special keys
  1597. todo: true
  1598. yaml: |
  1599. "!": These three keys
  1600. "&": had to be quoted
  1601. "=": and are normal strings.
  1602. # NOTE: the following node should NOT be serialized this way.
  1603. encoded node :
  1604. !special '!' : '!type'
  1605. !special|canonical '&' : 12
  1606. = : value
  1607. # The proper way to serialize the above node is as follows:
  1608. node : !!type &12 value
  1609. ruby: |
  1610. { '!' => 'These three keys', '&' => 'had to be quoted',
  1611. '=' => 'and are normal strings.',
  1612. 'encoded node' => YAML::PrivateType.new( 'type', 'value' ),
  1613. 'node' => YAML::PrivateType.new( 'type', 'value' ) }