From 8273f9dd219f9a0c5e9cc8dbcc05028b3217a586 Mon Sep 17 00:00:00 2001 From: Nicolas Payette Date: Sat, 11 Nov 2017 19:11:02 +0100 Subject: [PATCH] add a language test in the (failed) hope of catching #162 It seems like the values *do* get set correctly on import, they're just not showing in the swing widgets. --- tests/export-import-preserves-values.json | 226 ++++++++++++++++++++++ xw/tests.txt | 26 +++ 2 files changed, 252 insertions(+) create mode 100644 tests/export-import-preserves-values.json diff --git a/tests/export-import-preserves-values.json b/tests/export-import-preserves-values.json new file mode 100644 index 0000000..60c3ec5 --- /dev/null +++ b/tests/export-import-preserves-values.json @@ -0,0 +1,226 @@ +{ + "b":{ + "COLOR":[ + 188.0, + 188.0, + 230.0, + 255.0 + ], + "COMMANDS":"print \"hello world\"", + "ENABLED?":true, + "FONT-COLOR":0.0, + "FONT-SIZE":12.0, + "HEIGHT":50.0, + "HIDDEN?":false, + "KEY":"b", + "KIND":"BUTTON", + "LABEL":"", + "TAB":"t1", + "WIDTH":150.0, + "X":10.0, + "Y":10.0 + }, + "ti":{ + "COLOR":[ + 130.0, + 188.0, + 183.0, + 255.0 + ], + "ENABLED?":true, + "FONT-COLOR":0.0, + "FONT-SIZE":12.0, + "HEIGHT":50.0, + "HIDDEN?":false, + "KEY":"ti", + "KIND":"TEXT-INPUT", + "LABEL":"", + "OPAQUE?":true, + "TAB":"t1", + "TEXT":"a", + "WIDTH":150.0, + "X":10.0, + "Y":10.0 + }, + "mc":{ + "COLOR":[ + 130.0, + 188.0, + 183.0, + 255.0 + ], + "ENABLED?":true, + "FONT-COLOR":0.0, + "FONT-SIZE":12.0, + "HEIGHT":100.0, + "HIDDEN?":false, + "ITEMS":[ + "a", + "b", + "c", + "d" + ], + "KEY":"mc", + "KIND":"MULTI-CHOOSER", + "LABEL":"", + "OPAQUE?":true, + "SELECTED-ITEMS":[ + "b", + "c" + ], + "TAB":"t1", + "WIDTH":150.0, + "X":10.0, + "Y":10.0 + }, + "ni":{ + "COLOR":[ + 130.0, + 188.0, + 183.0, + 255.0 + ], + "ENABLED?":true, + "FONT-COLOR":0.0, + "FONT-SIZE":12.0, + "HEIGHT":50.0, + "HIDDEN?":false, + "KEY":"ni", + "KIND":"NUMERIC-INPUT", + "LABEL":"", + "OPAQUE?":true, + "TAB":"t1", + "VALUE":10.0, + "WIDTH":150.0, + "X":10.0, + "Y":10.0 + }, + "t1":{ + "COLOR":9.9, + "ENABLED?":true, + "KEY":"t1", + "KIND":"TAB", + "ORDER":0.0, + "TITLE":"" + }, + "c1":{ + "COLOR":[ + 130.0, + 188.0, + 183.0, + 255.0 + ], + "ENABLED?":true, + "FONT-COLOR":0.0, + "FONT-SIZE":12.0, + "HEIGHT":50.0, + "HIDDEN?":false, + "ITEMS":[ + "a", + "b", + "c", + "d" + ], + "KEY":"c1", + "KIND":"CHOOSER", + "LABEL":"", + "OPAQUE?":true, + "SELECTED-ITEM":"b", + "TAB":"t1", + "WIDTH":150.0, + "X":10.0, + "Y":10.0 + }, + "n":{ + "COLOR":9.9, + "ENABLED?":true, + "FONT-COLOR":0.0, + "FONT-SIZE":12.0, + "HEIGHT":25.0, + "HIDDEN?":false, + "KEY":"n", + "KIND":"NOTE", + "OPAQUE?":false, + "TAB":"t1", + "TEXT":"a", + "WIDTH":150.0, + "X":10.0, + "Y":10.0 + }, + "s1":{ + "COLOR":[ + 130.0, + 188.0, + 183.0, + 255.0 + ], + "ENABLED?":true, + "FONT-COLOR":0.0, + "FONT-SIZE":12.0, + "HEIGHT":50.0, + "HIDDEN?":false, + "INCREMENT":1.0, + "KEY":"s1", + "KIND":"SLIDER", + "LABEL":"", + "MAXIMUM":100.0, + "MINIMUM":0.0, + "OPAQUE?":true, + "TAB":"t1", + "UNITS":"", + "VALUE":10.0, + "WIDTH":150.0, + "X":10.0, + "Y":10.0 + }, + "c2":{ + "COLOR":[ + 130.0, + 188.0, + 183.0, + 255.0 + ], + "ENABLED?":true, + "FONT-COLOR":0.0, + "FONT-SIZE":12.0, + "HEIGHT":50.0, + "HIDDEN?":false, + "ITEMS":[ + 1.0, + 2.0, + 3.0, + 4.0 + ], + "KEY":"c2", + "KIND":"CHOOSER", + "LABEL":"", + "OPAQUE?":true, + "SELECTED-ITEM":2.0, + "TAB":"t1", + "WIDTH":150.0, + "X":10.0, + "Y":10.0 + }, + "cb":{ + "COLOR":[ + 130.0, + 188.0, + 183.0, + 255.0 + ], + "ENABLED?":false, + "FONT-COLOR":0.0, + "FONT-SIZE":12.0, + "HEIGHT":25.0, + "HIDDEN?":false, + "KEY":"cb", + "KIND":"CHECKBOX", + "LABEL":"", + "OPAQUE?":true, + "SELECTED?":false, + "TAB":"t1", + "WIDTH":150.0, + "X":10.0, + "Y":10.0 + } +} \ No newline at end of file diff --git a/xw/tests.txt b/xw/tests.txt index 430f650..a778709 100644 --- a/xw/tests.txt +++ b/xw/tests.txt @@ -174,6 +174,32 @@ test-export-import glob1 = glob2 => true O> file-close-all +export-import-preserves-values + extensions [xw] + O> xw:clear-all + O> xw:create-tab "t1" + O> xw:create-slider "s1" [ xw:set-value 10 ] + O> xw:create-chooser "c1" [ xw:set-items ["a" "b" "c" "d"] xw:set-selected-item "b" ] + O> xw:create-chooser "c2" [ xw:set-items [1 2 3 4] xw:set-selected-item 2 ] + O> xw:create-note "n" [ xw:set-text "a" ] + O> xw:create-checkbox "cb" [ xw:set-enabled? false ] + O> xw:create-multi-chooser "mc" [ xw:set-items [ "a" "b" "c" "d"] xw:set-selected-items ["b" "c"] ] + O> xw:create-text-input "ti" [ xw:set-text "a" ] + O> xw:create-numeric-input "ni" [ xw:set-value 10 ] + O> xw:create-button "b" [ xw:set-commands "print \"hello world\"" ] + O> xw:export "tests/export-import-preserves-values.json" + O> xw:clear-all + O> xw:import "tests/export-import-preserves-values.json" + xw:get "s1" => 10 + xw:get "c1" => "b" + xw:get "c2" => 2 + xw:get "n" => "a" + xw:get "cb" => false + xw:get "mc" => ["b" "c"] + xw:get "ti" => "a" + xw:get "ni" => 10 + [ xw:commands ] xw:of "b" => "print \"hello world\"" + import-multiple-files extensions [xw] O> xw:create-tab "t1"