Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Huddle fixes #42

Merged
merged 4 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions generic/yajltcl.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ parse2huddle_null_callback (void *context)
{
yajltcl_clientData *yajlData = context;

Tcl_DStringAppendElement (&yajlData->p2dString, "s null");
Tcl_DStringAppendElement (&yajlData->p2dString, "null");
return 1;
}

Expand All @@ -456,7 +456,7 @@ parse2huddle_boolean_callback (void *context, int boolean)
{
yajltcl_clientData *yajlData = context;

Tcl_DStringAppendElement (&yajlData->p2dString, boolean ? "1" : "0");
Tcl_DStringAppendElement (&yajlData->p2dString, boolean ? "b true" : "b false");
return 1;
}

Expand All @@ -467,7 +467,7 @@ parse2huddle_number_callback (void *context, const char *s, size_t l)
{
yajltcl_clientData *yajlData = context;

Tcl_DStringAppend (&yajlData->p2dString, "{s ",3);
Tcl_DStringAppend (&yajlData->p2dString, "{num ", 5);

Tcl_DStringSetLength (&yajlData->dString, 0);
Tcl_DStringAppend (&yajlData->dString, s, l);
Expand Down
29 changes: 21 additions & 8 deletions tests/huddle.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ namespace eval ::yajl::test {
set json_obj [yajl create #auto -beautify 0]
set yajlstr2 [$json_obj parse $json]
$json_obj delete

# TODO: test next 2 lines are just a hack because the conversion to huddle is lossy with number types?
set yajlstr [string map {number string} $yajlstr]
set yajlstr2 [string map {number string} $yajlstr2]

if {$yajlstr2 != $yajlstr} {
puts "YAJL:\t\t$yajlstr"
Expand Down Expand Up @@ -66,10 +62,10 @@ namespace eval ::yajl::test {
} -result 1

# TODO: this test currently fails
# test 1.04 {: Array with null element
# } -body {
# dotest {{"moo": "cow", "pig": "oink", "rabbit" : null}}
# } -result 1
test 1.04 {: Array with null element
} -body {
dotest {{"moo": "cow", "pig": "oink", "rabbit" : null}}
} -result 1


test 1.05 {: example from the yajl-tcl README file.
Expand Down Expand Up @@ -154,6 +150,23 @@ namespace eval ::yajl::test {
}}
} -result 1

# HUDDLE {D {A {b true}}}
test 1.08 {: basic types boolean
} -body {
dotest {{"key": true}}
} -result 1

# HUDDLE {D {A {num 42}}}
test 1.09 {: basic types integer
} -body {
dotest {{"key": 42}}
} -result 1

# HUDDLE {D {A null}}
test 1.11 {: basic types null
} -body {
dotest {{"key": null}}
} -result 1
}

cleanupTests
Loading