!! Version 2 # Force the test runner to ensure the extension is loaded !! functionhooks af_get !! endfunctionhooks # This file tests the #af_get parser function !! test Test get numeric key !! wikitext {{#af_get: {{#af_list: a | b | c }} | 0 }}{{#af_get: {{#af_list: a | b | c }} | 1 }} !! html

ab

!! end !! test Test get string key !! wikitext {{#af_get: {{#af_object: foo=bar | boo=far }} | boo }} !! html

far

!! end !! test Test get boolean !! wikitext {{#af_print: {{#af_get: {{#af_list: {{#af_bool: yes }} }} | 0 }} }} !! html

true

!! end !! test Test get list !! wikitext {{#af_print: {{#af_get: {{#af_list: {{#af_list: a | b | c }} }} | 0 }} }} !! html !! end !! test Test get nested value, numeric keys !! wikitext {{#af_get: {{#af_list: {{#af_list: a | b | c }} }} | 0 | 1 }} !! html

b

!! end !! test Test get nested value, string keys !! wikitext {{#af_get: {{#af_object: foo={{#af_object: foo=bar | boo=far }} }} | foo | boo }} !! html

far

!! end !! test Test get nested value, mixed keys !! wikitext {{#af_get: {{#af_list: {{#af_object: foo=bar | boo=far }} }} | 0 | boo }} !! html

far

!! end !! test Test get value, numeric string keys !! wikitext {{#af_get: {{#af_object: 0=foo | 1=bar }} | 1 }} !! html

bar

!! end !! test Test get non-existent value !! wikitext {{#af_get: {{#af_object: foo=foo | boo=bar }} | quz }} !! html !! end !! test Test get non-existent value in subarray !! wikitext {{#af_get: {{#af_list: a | b | {{#af_list: c | d }} }} | 2 | 2 }} !! html !! end !! test Test get no keys !! wikitext {{#af_print: {{#af_get: {{#af_object: foo=foo | boo=bar }} }} }} !! html !! end !! test Test invalid type for first argument !! wikitext {{#af_get: foobar }} !! html

ArrayFunctions (#af_get): Could not match expected type array with actual type string for parameter 1 ("foobar").

!! end