Skip to content

Commit

Permalink
Rename tobool to toboolean
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny committed Jan 25, 2025
1 parent 1251787 commit 8af260c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions docs/content/manual/dev/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1476,15 +1476,15 @@ sections:
input: '[1, "1"]'
output: ['1', '1']

- title: "`tobool`"
- title: "`toboolean`"
body: |
The `tobool` function parses its input as a boolean. It
The `toboolean` function parses its input as a boolean. It
will convert correctly-formatted strings to their boolean
equivalent, leave booleans alone, and give an error on all other input.
examples:
- program: '.[] | tobool'
- program: '.[] | toboolean'
input: '["true", "false", true, false]'
output: ['true', 'false', 'true', 'false']

Expand Down
6 changes: 3 additions & 3 deletions jq.1.prebuilt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ static jv f_tonumber(jq_state *jq, jv input) {
return type_error(input, "cannot be parsed as a number");
}

static jv f_tobool(jq_state *jq, jv input) {
static jv f_toboolean(jq_state *jq, jv input) {
if (jv_get_kind(input) == JV_KIND_TRUE || jv_get_kind(input) == JV_KIND_FALSE) {
return input;
}
Expand Down Expand Up @@ -1867,7 +1867,7 @@ BINOPS
CFUNC(f_dump, "tojson", 1),
CFUNC(f_json_parse, "fromjson", 1),
CFUNC(f_tonumber, "tonumber", 1),
CFUNC(f_tobool, "tobool", 1),
CFUNC(f_toboolean, "toboolean", 1),
CFUNC(f_tostring, "tostring", 1),
CFUNC(f_keys, "keys", 1),
CFUNC(f_keys_unsorted, "keys_unsorted", 1),
Expand Down
4 changes: 2 additions & 2 deletions tests/jq.test
Original file line number Diff line number Diff line change
Expand Up @@ -638,11 +638,11 @@ null
4
15

map(tobool)
map(toboolean)
["false","true",false,true]
[false,true,false,true]

.[] | try tobool catch .
.[] | try toboolean catch .
[null,0,"tru","truee","fals","falsee",[],{}]
"null (null) cannot be parsed as a boolean"
"number (0) cannot be parsed as a boolean"
Expand Down
2 changes: 1 addition & 1 deletion tests/man.test

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8af260c

Please sign in to comment.