diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-05-01 18:54:18 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-05-01 19:08:37 +0100 |
| commit | bebc3653452c60e64e14a1a7d1b476ee75b2ae8a (patch) | |
| tree | e2e3b89d183c23fab20b95bb4ed59b0cc279a80f /tests | |
| parent | 888d37322643fd099008d76f12184648047d7204 (diff) | |
Add slurp support
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/jq_tests.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/jq_tests.py b/tests/jq_tests.py index d97f2bd..5f6bb16 100644 --- a/tests/jq_tests.py +++ b/tests/jq_tests.py @@ -97,6 +97,30 @@ def test_input_can_be_text_with_multiple_values_separated_by_newlines(): assert_equal([1, 2, 3], result) +def test_slurping_input_text_reads_input_as_single_array(): + program = jq.compile(".") + + result = program.input_text("1\n2\n3\n", slurp=True).all() + + assert_equal([[1, 2, 3]], result) + + +def test_can_slurp_without_trailing_newline(): + program = jq.compile(".") + + result = program.input_text("1\n2\n3", slurp=True).all() + + assert_equal([[1, 2, 3]], result) + + +def test_can_slurp_and_produce_multiple_output_values(): + program = jq.compile(".[]") + + result = program.input_text("1\n2\n3", slurp=True).all() + + assert_equal([1, 2, 3], result) + + def test_when_text_method_is_used_on_result_then_output_is_serialised_to_json_string(): assert_equal( '"42"', |
