test cases for set of parameter added, plus some corrections
This commit is contained in:
parent
8c6c1e5dc8
commit
b4b7ef926e
11 changed files with 285 additions and 9 deletions
|
|
@ -279,7 +279,7 @@ void ParameterWidget::applyParameterSet(string setName){
|
|||
AssignmentList *assignmentList;
|
||||
assignmentList=parser(v.second.data().c_str());
|
||||
if(assignmentList==NULL){
|
||||
return ;
|
||||
continue ;
|
||||
}
|
||||
|
||||
ModuleContext ctx;
|
||||
|
|
|
|||
|
|
@ -68,12 +68,12 @@ void ParameterSet::applyParameterSet(FileModule *fileModule,string setName)
|
|||
AssignmentList *assignmentList;
|
||||
assignmentList=parser(v.second.data().c_str());
|
||||
if(assignmentList==NULL){
|
||||
return ;
|
||||
continue ;
|
||||
}
|
||||
ModuleContext ctx;
|
||||
for(int i=0; i<assignmentList->size(); i++) {
|
||||
if(defaultValue->type()== assignmentList[i].data()->expr.get()->evaluate(&ctx)->type()){
|
||||
assignment=assignmentList[i].data();
|
||||
assignment->expr=assignmentList[i].data()->expr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
39
testdata/scad/customizer/setofparameter.json
vendored
Normal file
39
testdata/scad/customizer/setofparameter.json
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"SET":
|
||||
{
|
||||
"firstSet":
|
||||
{
|
||||
"Labeled_value": " \/*New *\/ ",
|
||||
"Labeled_values": "100",
|
||||
"Numbers": "1",
|
||||
"Spinbox": "35",
|
||||
"String": "hello",
|
||||
"Strings": "foo",
|
||||
"Variable": "false",
|
||||
"Vector": "[2, 34, 45, 12, 3, 56]",
|
||||
"Vector2": "[12,4, 45, 23]",
|
||||
"slider": "38",
|
||||
"stepSlider": "12"
|
||||
},
|
||||
"wrongSetValues":
|
||||
{
|
||||
"Labeled_value": "S new",
|
||||
"Labeled_values": "wrong type",
|
||||
"Numbers": "2",
|
||||
"Spinbox": "5",
|
||||
"String": "1234",
|
||||
"Strings": "fo",
|
||||
"Variable": "true",
|
||||
"Vector": "12, 34, 44, 43, 2, 23",
|
||||
"Vector2": "[12, 34, 45, 23]",
|
||||
"slider": "34",
|
||||
"stepSlider": "2"
|
||||
},
|
||||
"thirdSet":
|
||||
{
|
||||
"Labeled_value":"S new",
|
||||
"non existing":"value",
|
||||
"nonparameter" : "second"
|
||||
}
|
||||
}
|
||||
}
|
||||
45
testdata/scad/customizer/setofparameter.scad
vendored
Normal file
45
testdata/scad/customizer/setofparameter.scad
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/* [Drop down box:] */
|
||||
// combo box for nunber
|
||||
Numbers=2; // [0, 1, 2, 3]
|
||||
|
||||
// combo box for string
|
||||
Strings="foo";
|
||||
|
||||
//labeled combo box for numbers
|
||||
Labeled_values=10; // [10:L, 20:M, 30:L]
|
||||
|
||||
//labeled combo box for string
|
||||
Labeled_value="S"; // [S:Small, M:Medium, L:Large]
|
||||
|
||||
/*[ Slider ]*/
|
||||
// slider widget for number
|
||||
slider =34; // [10:100]
|
||||
|
||||
//step slider for number
|
||||
stepSlider=2; //[0:5:100]
|
||||
|
||||
/* [Checkbox] */
|
||||
|
||||
//description
|
||||
Variable = true; //comment
|
||||
|
||||
/*[Spinbox] */
|
||||
|
||||
// spinbox with step size 23
|
||||
Spinbox = 5; //23
|
||||
|
||||
/* [Textbox] */
|
||||
|
||||
//Text box for vector with more than 4 elements
|
||||
Vector=[12,34,44,43,23,23];//comment
|
||||
|
||||
// Text box for string
|
||||
String="hello"; //comment
|
||||
|
||||
/* [Special vector] */
|
||||
//Text box for vector with less than or equal to 4 elements
|
||||
Vector2=[12,34,45,23]; //any thing
|
||||
|
||||
nonparameter="new";
|
||||
|
||||
echo(String);
|
||||
|
|
@ -1590,6 +1590,10 @@ add_cmdline_test(customizertest EXE ${OPENSCAD_BINPATH} ARGS -o SUFFIX ast FILES
|
|||
add_cmdline_test(customizertest_secondset EXE ${OPENSCAD_BINPATH} ARGS -p ${CMAKE_SOURCE_DIR}/../testdata/scad/customizer/sign.json -P secondset -o SUFFIX ast FILES ${CMAKE_SOURCE_DIR}/../examples/Parametric/sign.scad)
|
||||
add_cmdline_test(customizertest_final EXE ${OPENSCAD_BINPATH} ARGS -p ${CMAKE_SOURCE_DIR}/../testdata/scad/customizer/sign.json -P final -o SUFFIX ast FILES ${CMAKE_SOURCE_DIR}/../examples/Parametric/sign.scad)
|
||||
|
||||
add_cmdline_test(customizertest-first EXE ${OPENSCAD_BINPATH} ARGS -p ${CMAKE_SOURCE_DIR}/../testdata/scad/customizer/setofparameter.json -P firstSet -o SUFFIX ast FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/customizer/setofparameter.scad)
|
||||
add_cmdline_test(customizertest-wrong EXE ${OPENSCAD_BINPATH} ARGS -p ${CMAKE_SOURCE_DIR}/../testdata/scad/customizer/setofparameter.json -P wrongSetValues -o SUFFIX ast FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/customizer/setofparameter.scad)
|
||||
add_cmdline_test(customizertest-incomplete EXE ${OPENSCAD_BINPATH} ARGS -p ${CMAKE_SOURCE_DIR}/../testdata/scad/customizer/setofparameter.json -P thirdSet -o SUFFIX ast FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/customizer/setofparameter.scad)
|
||||
add_cmdline_test(customizertest-imgset EXE ${OPENSCAD_BINPATH} ARGS -p ${CMAKE_SOURCE_DIR}/../testdata/scad/customizer/setofparameter.json -P imagine -o SUFFIX ast FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/customizer/setofparameter.scad)
|
||||
|
||||
#
|
||||
# Add experimental tests
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
@Group("Drop down box:")
|
||||
@Description("combo box for nunber")
|
||||
@Parameter([0, 1, 2, 3])
|
||||
Numbers = 1;
|
||||
@Group("Drop down box:")
|
||||
@Description("combo box for string")
|
||||
Strings = "foo";
|
||||
@Group("Drop down box:")
|
||||
@Description("labeled combo box for numbers")
|
||||
@Parameter([[10, "L"], [20, "M"], [30, "L"]])
|
||||
Labeled_values = 100;
|
||||
@Group("Drop down box:")
|
||||
@Description("labeled combo box for string")
|
||||
@Parameter([["S", "Small"], ["M", "Medium"], ["L", "Large"]])
|
||||
Labeled_value = " /*New */ ";
|
||||
@Group(" Slider ")
|
||||
@Description("slider widget for number")
|
||||
@Parameter([10 : 100])
|
||||
slider = 38;
|
||||
@Group(" Slider ")
|
||||
@Description("step slider for number")
|
||||
@Parameter([0 : 5 : 100])
|
||||
stepSlider = 12;
|
||||
@Group("Checkbox")
|
||||
@Description("description")
|
||||
@Parameter("comment")
|
||||
Variable = true;
|
||||
@Group("Spinbox")
|
||||
@Description("spinbox with step size 23")
|
||||
@Parameter(23)
|
||||
Spinbox = 35;
|
||||
@Group("Textbox")
|
||||
@Description("Text box for vector with more than 4 elements")
|
||||
@Parameter("comment")
|
||||
Vector = [2, 34, 45, 12, 3, 56];
|
||||
@Group("Textbox")
|
||||
@Description("Text box for string")
|
||||
@Parameter("comment")
|
||||
String = "hello";
|
||||
@Group("Special vector")
|
||||
@Description("Text box for vector with less than or equal to 4 elements")
|
||||
@Parameter("any thing")
|
||||
Vector2 = [12, 4, 45, 23];
|
||||
@Group("Special vector")
|
||||
nonparameter = "new";
|
||||
echo(String);
|
||||
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
@Group("Drop down box:")
|
||||
@Description("combo box for nunber")
|
||||
@Parameter([0, 1, 2, 3])
|
||||
Numbers = 2;
|
||||
@Group("Drop down box:")
|
||||
@Description("combo box for string")
|
||||
Strings = "foo";
|
||||
@Group("Drop down box:")
|
||||
@Description("labeled combo box for numbers")
|
||||
@Parameter([[10, "L"], [20, "M"], [30, "L"]])
|
||||
Labeled_values = 10;
|
||||
@Group("Drop down box:")
|
||||
@Description("labeled combo box for string")
|
||||
@Parameter([["S", "Small"], ["M", "Medium"], ["L", "Large"]])
|
||||
Labeled_value = "S";
|
||||
@Group(" Slider ")
|
||||
@Description("slider widget for number")
|
||||
@Parameter([10 : 100])
|
||||
slider = 34;
|
||||
@Group(" Slider ")
|
||||
@Description("step slider for number")
|
||||
@Parameter([0 : 5 : 100])
|
||||
stepSlider = 2;
|
||||
@Group("Checkbox")
|
||||
@Description("description")
|
||||
@Parameter("comment")
|
||||
Variable = true;
|
||||
@Group("Spinbox")
|
||||
@Description("spinbox with step size 23")
|
||||
@Parameter(23)
|
||||
Spinbox = 5;
|
||||
@Group("Textbox")
|
||||
@Description("Text box for vector with more than 4 elements")
|
||||
@Parameter("comment")
|
||||
Vector = [12, 34, 44, 43, 23, 23];
|
||||
@Group("Textbox")
|
||||
@Description("Text box for string")
|
||||
@Parameter("comment")
|
||||
String = "hello";
|
||||
@Group("Special vector")
|
||||
@Description("Text box for vector with less than or equal to 4 elements")
|
||||
@Parameter("any thing")
|
||||
Vector2 = [12, 34, 45, 23];
|
||||
@Group("Special vector")
|
||||
nonparameter = "new";
|
||||
echo(String);
|
||||
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
@Group("Drop down box:")
|
||||
@Description("combo box for nunber")
|
||||
@Parameter([0, 1, 2, 3])
|
||||
Numbers = 2;
|
||||
@Group("Drop down box:")
|
||||
@Description("combo box for string")
|
||||
Strings = "foo";
|
||||
@Group("Drop down box:")
|
||||
@Description("labeled combo box for numbers")
|
||||
@Parameter([[10, "L"], [20, "M"], [30, "L"]])
|
||||
Labeled_values = 10;
|
||||
@Group("Drop down box:")
|
||||
@Description("labeled combo box for string")
|
||||
@Parameter([["S", "Small"], ["M", "Medium"], ["L", "Large"]])
|
||||
Labeled_value = "S new";
|
||||
@Group(" Slider ")
|
||||
@Description("slider widget for number")
|
||||
@Parameter([10 : 100])
|
||||
slider = 34;
|
||||
@Group(" Slider ")
|
||||
@Description("step slider for number")
|
||||
@Parameter([0 : 5 : 100])
|
||||
stepSlider = 2;
|
||||
@Group("Checkbox")
|
||||
@Description("description")
|
||||
@Parameter("comment")
|
||||
Variable = true;
|
||||
@Group("Spinbox")
|
||||
@Description("spinbox with step size 23")
|
||||
@Parameter(23)
|
||||
Spinbox = 5;
|
||||
@Group("Textbox")
|
||||
@Description("Text box for vector with more than 4 elements")
|
||||
@Parameter("comment")
|
||||
Vector = [12, 34, 44, 43, 23, 23];
|
||||
@Group("Textbox")
|
||||
@Description("Text box for string")
|
||||
@Parameter("comment")
|
||||
String = "hello";
|
||||
@Group("Special vector")
|
||||
@Description("Text box for vector with less than or equal to 4 elements")
|
||||
@Parameter("any thing")
|
||||
Vector2 = [12, 34, 45, 23];
|
||||
@Group("Special vector")
|
||||
nonparameter = "second";
|
||||
echo(String);
|
||||
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
@Group("Drop down box:")
|
||||
@Description("combo box for nunber")
|
||||
@Parameter([0, 1, 2, 3])
|
||||
Numbers = 2;
|
||||
@Group("Drop down box:")
|
||||
@Description("combo box for string")
|
||||
Strings = "fo";
|
||||
@Group("Drop down box:")
|
||||
@Description("labeled combo box for numbers")
|
||||
@Parameter([[10, "L"], [20, "M"], [30, "L"]])
|
||||
Labeled_values = 10;
|
||||
@Group("Drop down box:")
|
||||
@Description("labeled combo box for string")
|
||||
@Parameter([["S", "Small"], ["M", "Medium"], ["L", "Large"]])
|
||||
Labeled_value = "S new";
|
||||
@Group(" Slider ")
|
||||
@Description("slider widget for number")
|
||||
@Parameter([10 : 100])
|
||||
slider = 34;
|
||||
@Group(" Slider ")
|
||||
@Description("step slider for number")
|
||||
@Parameter([0 : 5 : 100])
|
||||
stepSlider = 2;
|
||||
@Group("Checkbox")
|
||||
@Description("description")
|
||||
@Parameter("comment")
|
||||
Variable = true;
|
||||
@Group("Spinbox")
|
||||
@Description("spinbox with step size 23")
|
||||
@Parameter(23)
|
||||
Spinbox = 5;
|
||||
@Group("Textbox")
|
||||
@Description("Text box for vector with more than 4 elements")
|
||||
@Parameter("comment")
|
||||
Vector = [12, 34, 44, 43, 23, 23];
|
||||
@Group("Textbox")
|
||||
@Description("Text box for string")
|
||||
@Parameter("comment")
|
||||
String = "1234";
|
||||
@Group("Special vector")
|
||||
@Description("Text box for vector with less than or equal to 4 elements")
|
||||
@Parameter("any thing")
|
||||
Vector2 = [12, 34, 45, 23];
|
||||
@Group("Special vector")
|
||||
nonparameter = "new";
|
||||
echo(String);
|
||||
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
@Description("The resolution of the curves. Higher values give smoother curves but may increase the model render time.")
|
||||
@Parameter([10, 20, 30, 50, 100])
|
||||
resolution = 30;
|
||||
resolution = 100;
|
||||
@Description("The horizontal radius of the outer ellipse of the sign.")
|
||||
@Parameter([60 : 200])
|
||||
radius = 80;
|
||||
radius = 74;
|
||||
@Description("Total height of the sign")
|
||||
@Parameter([1 : 10])
|
||||
height = 2;
|
||||
height = 9;
|
||||
@Parameter(["Welcome to...", "Happy Birthday!", "Happy Anniversary", "Congratulations", "Thank You"])
|
||||
selection = "Thank You";
|
||||
@Parameter()
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
@Description("The resolution of the curves. Higher values give smoother curves but may increase the model render time.")
|
||||
@Parameter([10, 20, 30, 50, 100])
|
||||
resolution = 30;
|
||||
resolution = 50;
|
||||
@Description("The horizontal radius of the outer ellipse of the sign.")
|
||||
@Parameter([60 : 200])
|
||||
radius = 80;
|
||||
radius = 110;
|
||||
@Description("Total height of the sign")
|
||||
@Parameter([1 : 10])
|
||||
height = 2;
|
||||
height = 6;
|
||||
@Parameter(["Welcome to...", "Happy Birthday!", "Happy Anniversary", "Congratulations", "Thank You"])
|
||||
selection = "Happy Anniversary";
|
||||
@Parameter()
|
||||
|
|
|
|||
Loading…
Reference in a new issue