@@ -72,31 +72,32 @@ class MiscTests : public nodecpp::js::JSModule
7272 });
7373
7474public:
75- MiscTests ()
76- {
75+ MiscTests () {}
7776
78- JSOwnObj array_of_arrays1 = makeJSArray ({
77+ void AllTests () {
78+
79+ JSOwnObj array_of_arrays1 = makeJSArray ({
7980 makeJSArray ({" reset" , 0 , 0 }),
8081 makeJSArray ({" bold" , 1 , 22 }),
8182 makeJSArray ({" dim" , 2 , 22 }),
8283 makeJSArray ({" num" , 3 }),
8384 makeJSArray ({" str" , " some str" }),
8485 " just a string" ,
8586 makeJSObject ({
86- { " key1" , " val1" },
87- { " key2" , makeJSObject ({
87+ { " key1" , " val1" },
88+ { " key2" , makeJSObject ({
8889 { " key1-1" , " val1-1" } }) }
89- } )
90- });
90+ })
91+ });
9192
9293 JSOwnObj* pobj = &array_of_arrays1;
9394 nodecpp::safememory::owning_ptr<JSObject>* pown = reinterpret_cast <nodecpp::safememory::owning_ptr<JSObject>*>(pobj);
9495 JSObject& obj1 = *(*pown);
9596
96- JSOwnObj arr1 = makeJSArray ({0 , 0 });
97- JSOwnObj arr2 = makeJSArray ({1 , 22 });
97+ JSOwnObj arr1 = makeJSArray ({ 0 , 0 });
98+ JSOwnObj arr2 = makeJSArray ({ 1 , 22 });
9899
99- JSOwnObj object_with_explicit_types_2 = makeJSObject ({
100+ JSOwnObj object_with_explicit_types_2 = makeJSObject ({
100101 { " reset" , nodecpp::move (arr1) },
101102 { " bold" , arr2 },
102103 { " dim" , makeJSArray ({2 , 22 }) },
@@ -107,129 +108,129 @@ class MiscTests : public nodecpp::js::JSModule
107108 { " concat2" , JSVar ([](JSVar x1, JSVar x2) { return x1.toString () + x2.toString (); }) },
108109 { " concat3" , JSVar ([](JSVar x1, JSVar x2, JSVar x3) { return x1.toString () + x2.toString () + x3.toString (); }) },
109110 { " concat4" , JSVar ([](JSVar x1, JSVar x2, JSVar x3, JSVar x4) { return x1.toString () + x2.toString () + x3.toString () + x4.toString (); }) },
110- { " concat_any" , JSVar ([]() {
111+ { " concat_any" , JSVar ([]() {
111112 nodecpp::string ret = " " ;
112113 JSVar params = arguments ();
113- params.forEach ( [&ret, params](JSVar idx){
114+ params.forEach ([&ret, params](JSVar idx) {
114115 ret += params[idx].toString ();
115116 });
116117 return ret;
117118 }) },
118- { " prefix adder generator" , JSVar ([](JSVar prefix) { return JSVar ( [prefix](JSVar s){ return prefix.toString () + s.toString ();});}) },
119-
120- });
119+ { " prefix adder generator" , JSVar ([](JSVar prefix) { return JSVar ([prefix](JSVar s) { return prefix.toString () + s.toString (); }); }) },
120+
121+ });
121122
122123 arr2[0 ] = 999 ;
123124
124- JSVar prefixAdder = object_with_explicit_types_2[" prefix adder generator" ]( " prefix + " );
125+ JSVar prefixAdder = object_with_explicit_types_2[" prefix adder generator" ](" prefix + " );
125126 JSVar strvar = " some text" ;
126127 JSVar arrvar = object_with_explicit_types_2[" bold" ];
127128 JSVar numvar = 17 ;
128129 JSVar boolvar = true ;
129130
130131
131- console.log ( " \n ======\n {}\n =======\n " , object_with_explicit_types );
132- console.log ( " \n ======\n {}\n =======\n " , array_of_arrays );
133- console.log ( " \n ======\n {}\n =======\n " , object_with_explicit_types_2 );
134- console.log ( " \n ======\n {}\n =======\n " , object_with_explicit_types_2[" getStr" ]() );
135- console.log ( " \n ======\n {}\n =======\n " , object_with_explicit_types_2[" echo" ]( " echoing my cry" ) );
136- console.log ( " \n ======\n {}\n =======\n " , object_with_explicit_types_2[" concat2" ]( " word1 " , " word2 " ) );
137- console.log ( " \n ======\n {}\n =======\n " , object_with_explicit_types_2[" concat3" ]( " word1 " , " word2 " , " word3 " ) );
138- console.log ( " \n ======\n {}\n =======\n " , object_with_explicit_types_2[" concat4" ]( " word1 " , " word2 " , " word3 " , " word4 " ) );
139- console.log ( " \n ======\n {}\n =======\n " , object_with_explicit_types_2[" concat4" ]( " word1 " , " word2 " , " word3 " ) );
140- console.log ( " \n ======\n {}\n =======\n " , object_with_explicit_types_2[" concat4" ]( " word1 " , " word2 " ) );
141- console.log ( " \n ======\n {}\n =======\n " , object_with_explicit_types_2[" concat4" ]( " word1 " ) );
142- console.log ( " \n ======\n {}\n =======\n " , object_with_explicit_types_2[" concat4" ]() );
143- console.log ( " \n ======\n {}\n =======\n " , object_with_explicit_types_2[" concat_any" ]( " word1 " , " word2 " , " word3 " , " word4 " ) );
144- console.log ( " \n ======\n {}\n =======\n " , prefixAdder ( " some text after" ) );
132+ console.log (" \n ======\n {}\n =======\n " , object_with_explicit_types);
133+ console.log (" \n ======\n {}\n =======\n " , array_of_arrays);
134+ console.log (" \n ======\n {}\n =======\n " , object_with_explicit_types_2);
135+ console.log (" \n ======\n {}\n =======\n " , object_with_explicit_types_2[" getStr" ]());
136+ console.log (" \n ======\n {}\n =======\n " , object_with_explicit_types_2[" echo" ](" echoing my cry" ) );
137+ console.log (" \n ======\n {}\n =======\n " , object_with_explicit_types_2[" concat2" ](" word1 " , " word2 " ) );
138+ console.log (" \n ======\n {}\n =======\n " , object_with_explicit_types_2[" concat3" ](" word1 " , " word2 " , " word3 " ) );
139+ console.log (" \n ======\n {}\n =======\n " , object_with_explicit_types_2[" concat4" ](" word1 " , " word2 " , " word3 " , " word4 " ) );
140+ console.log (" \n ======\n {}\n =======\n " , object_with_explicit_types_2[" concat4" ](" word1 " , " word2 " , " word3 " ) );
141+ console.log (" \n ======\n {}\n =======\n " , object_with_explicit_types_2[" concat4" ](" word1 " , " word2 " ) );
142+ console.log (" \n ======\n {}\n =======\n " , object_with_explicit_types_2[" concat4" ](" word1 " ) );
143+ console.log (" \n ======\n {}\n =======\n " , object_with_explicit_types_2[" concat4" ]());
144+ console.log (" \n ======\n {}\n =======\n " , object_with_explicit_types_2[" concat_any" ](" word1 " , " word2 " , " word3 " , " word4 " ) );
145+ console.log (" \n ======\n {}\n =======\n " , prefixAdder (" some text after" ) );
145146
146147 // misc math, etc
147- console.log ( " \n ======math=======\n " );
148- console.log ( JSVar (3.5 ) % JSVar (2 ));
149- console.log ( JSVar (-3.5 ) % JSVar (2 ));
150- console.log ( JSVar (7.5 ) % JSVar (2.4 ));
151- console.log ( JSVar (" 7.5" ) % JSVar (" 2.4" ));
152-
153- console.log ( JSVar (" abc" ) || JSVar (" def" ));
154- console.log ( JSVar (" " ) || JSVar (" def" ));
155- console.log ( JSVar () || JSVar (" def" ));
156- console.log ( JSVar (false ) || JSVar (" def" ));
157-
158- console.log ( JSVar (" ghi" ) && JSVar (" jkl" ));
159- console.log ( JSVar (" ghi" ) && JSVar (" " ));
160- console.log ( JSVar (" " ) && JSVar (" jkl" ));
161- console.log ( JSVar (" ghi" ) && JSVar ());
162- console.log ( JSVar (" ghi" ) && JSVar (false ));
163-
164- console.log ( (JSVar (" 3" ))++);
165- console.log ( ++(JSVar (" 3" )));
166- console.log ( (JSVar (" 3" ))--);
167- console.log ( --(JSVar (" 3" )));
168-
169- console.log ( (JSVar (" abc" )).split ());
170- console.log ( (JSVar (" abc" )).split (" " ));
171- console.log ( (JSVar (" abc def ghi" )).split (" " ));
172- console.log ( (JSVar (" abc def ghi " )).split ( " " ));
173-
174- console.log ( (array_of_arrays1[" 0" ].concat ( array_of_arrays1[" 1" ], array_of_arrays1[" 2" ] )));
175- console.log ( ((makeJSArray ())->concat (array_of_arrays1[" 0" ], array_of_arrays1[" 1" ], array_of_arrays1[" 2" ] )));
176-
177- console.log ( " \n ======\n {}\n =======\n " , array_of_arrays1.length () );
178- console.log ( " \n ======\n {}\n =======\n " , array_of_arrays1[" 0" ].length () );
148+ console.log (" \n ======math=======\n " );
149+ console.log (JSVar (3.5 ) % JSVar (2 ));
150+ console.log (JSVar (-3.5 ) % JSVar (2 ));
151+ console.log (JSVar (7.5 ) % JSVar (2.4 ));
152+ console.log (JSVar (" 7.5" ) % JSVar (" 2.4" ));
153+
154+ console.log (JSVar (" abc" ) || JSVar (" def" ));
155+ console.log (JSVar (" " ) || JSVar (" def" ));
156+ console.log (JSVar () || JSVar (" def" ));
157+ console.log (JSVar (false ) || JSVar (" def" ));
158+
159+ console.log (JSVar (" ghi" ) && JSVar (" jkl" ));
160+ console.log (JSVar (" ghi" ) && JSVar (" " ));
161+ console.log (JSVar (" " ) && JSVar (" jkl" ));
162+ console.log (JSVar (" ghi" ) && JSVar ());
163+ console.log (JSVar (" ghi" ) && JSVar (false ));
164+
165+ console.log ((JSVar (" 3" ))++);
166+ console.log (++(JSVar (" 3" )));
167+ console.log ((JSVar (" 3" ))--);
168+ console.log (--(JSVar (" 3" )));
169+
170+ console.log ((JSVar (" abc" )).split ());
171+ console.log ((JSVar (" abc" )).split (" " ));
172+ console.log ((JSVar (" abc def ghi" )).split (" " ));
173+ console.log ((JSVar (" abc def ghi " )).split (" " ));
174+
175+ console.log ((array_of_arrays1[" 0" ].concat (array_of_arrays1[" 1" ], array_of_arrays1[" 2" ])));
176+ console.log (((makeJSArray ())->concat (array_of_arrays1[" 0" ], array_of_arrays1[" 1" ], array_of_arrays1[" 2" ])));
177+
178+ console.log (" \n ======\n {}\n =======\n " , array_of_arrays1.length ());
179+ console.log (" \n ======\n {}\n =======\n " , array_of_arrays1[" 0" ].length ());
179180
180181 console.log (JSMath::floor (JSVar (3.14 )));
181182 console.log (JSMath::floor (JSVar (-3.14 )));
182183
183- console.log ( JSMath::random () );
184- console.log ( JSMath::random () );
185- console.log ( JSMath::random () );
184+ console.log (JSMath::random ());
185+ console.log (JSMath::random ());
186+ console.log (JSMath::random ());
186187
187- console.log ( (JSVar (" 3_AbCd, #" )).toLowerCase () );
188- console.log ( (JSVar (" 3_AbCd, #" )).toUpperCase () );
188+ console.log ((JSVar (" 3_AbCd, #" )).toLowerCase ());
189+ console.log ((JSVar (" 3_AbCd, #" )).toUpperCase ());
189190
190- console.log ( JSVar (3 ) += JSVar (4 ) );
191- console.log ( JSVar (3 ) += JSVar (" 4" ) );
192- console.log ( JSVar (" 3" ) += JSVar (4 ) );
193- console.log ( JSVar (3 ) += JSVar (true ) );
194- console.log ( JSVar (" 3" ) += JSVar (false ) );
195- console.log ( JSVar (true ) += JSVar (" 4" ) );
191+ console.log (JSVar (3 ) += JSVar (4 ));
192+ console.log (JSVar (3 ) += JSVar (" 4" ));
193+ console.log (JSVar (" 3" ) += JSVar (4 ));
194+ console.log (JSVar (3 ) += JSVar (true ));
195+ console.log (JSVar (" 3" ) += JSVar (false ));
196+ console.log (JSVar (true ) += JSVar (" 4" ));
196197
197- console.log ( JSVar (3 ) + JSVar (4 ) );
198- console.log ( JSVar (3 ) + JSVar (" 4" ) );
199- console.log ( JSVar (" 3" ) + JSVar (4 ) );
200- console.log ( JSVar (3 ) + JSVar (true ) );
201- console.log ( JSVar (" 3" ) + JSVar (false ) );
202- console.log ( JSVar (true ) + JSVar (" 4" ) );
198+ console.log (JSVar (3 ) + JSVar (4 ));
199+ console.log (JSVar (3 ) + JSVar (" 4" ));
200+ console.log (JSVar (" 3" ) + JSVar (4 ));
201+ console.log (JSVar (3 ) + JSVar (true ));
202+ console.log (JSVar (" 3" ) + JSVar (false ));
203+ console.log (JSVar (true ) + JSVar (" 4" ));
203204
204- console.log ( JSVar (" Some people when confronted with a problem think I know Ill use regular expressions Now they have two problems" ).match ( JSRegExp ( " ([a-zA-Z]+)[, .]" , " g" )));
205- console.log ( JSVar (" Quick brown fox" ).replace ( JSRegExp ( " a|e|i|o|u" , " g" ), JSVar (" *" ) ));
205+ console.log (JSVar (" Some people when confronted with a problem think I know Ill use regular expressions Now they have two problems" ).match (JSRegExp (" ([a-zA-Z]+)[, .]" , " g" )));
206+ console.log (JSVar (" Quick brown fox" ).replace (JSRegExp (" a|e|i|o|u" , " g" ), JSVar (" *" )));
206207
207208 JSVar tested4matching = " uoaieaoau" ;
208- console.log ( tested4matching + ( JSRegExp ( " [a|e|i|o|u]" , " g" ).test ( tested4matching ) ? " matches" : " not matches" ) );
209+ console.log (tested4matching + (JSRegExp (" [a|e|i|o|u]" , " g" ).test (tested4matching) ? " matches" : " not matches" ) );
209210
210211 JSOwnObj arrUnderConstr = makeJSArray ();
211- JSOwnObj tmpObjToPush_2 = makeJSObject ({
212+ JSOwnObj tmpObjToPush_2 = makeJSObject ({
212213 { " 111" , " 222" },
213214 { " 333" , " 444" }
214215 });
215- console.log ( JSVar (arrUnderConstr) );
216+ console.log (JSVar (arrUnderConstr));
216217 {
217- JSOwnObj tmpObjToPush = makeJSObject ({
218+ JSOwnObj tmpObjToPush = makeJSObject ({
218219 { " aaa" , " bbb" },
219220 { " ccc" , " ddd" }
220221 });
221- arrUnderConstr.push ( " abc" , " def" , " klm" , std::move ( tmpObjToPush ), tmpObjToPush_2 );
222+ arrUnderConstr.push (" abc" , " def" , " klm" , std::move (tmpObjToPush), tmpObjToPush_2);
222223 }
223- console.log ( JSVar (arrUnderConstr) );
224- console.log ( " ~~~~~~~~~~~~~~" );
225- console.log ( JSVar (tmpObjToPush_2) );
224+ console.log (JSVar (arrUnderConstr));
225+ console.log (" ~~~~~~~~~~~~~~" );
226+ console.log (JSVar (tmpObjToPush_2));
226227
227228 JSVar ttext = " abc" ;
228229 JSOwnObj badarr = makeJSArray ({ 0 , 0 });
229- JSVar badvar = ttext.split ( " " );
230+ JSVar badvar = ttext.split (" " );
230231 badarr[0 ] = badvar;
231232 JSVar failed = badarr[0 ][1 ];
232- }
233+ }
233234};
234235
235236#endif // MISC_TESTS_H
0 commit comments