MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxRunTest

Function fxRunTest

xs/sources/xsAPI.c:1242–1281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1240}
1241
1242txBoolean fxRunTest(txMachine* the)
1243{
1244 txBoolean result;
1245
1246 switch (the->stack->kind) {
1247 case XS_UNDEFINED_KIND:
1248 case XS_NULL_KIND:
1249 result = 0;
1250 break;
1251 case XS_BOOLEAN_KIND:
1252 result = the->stack->value.boolean;
1253 break;
1254 case XS_INTEGER_KIND:
1255 result = (the->stack->value.integer == 0) ? 0 : 1;
1256 break;
1257 case XS_NUMBER_KIND:
1258 switch (c_fpclassify(the->stack->value.number)) {
1259 case C_FP_NAN:
1260 case C_FP_ZERO:
1261 result = 0;
1262 break;
1263 default:
1264 result = 1;
1265 break;
1266 }
1267 break;
1268 case XS_STRING_KIND:
1269 case XS_STRING_X_KIND:
1270 if (c_isEmpty(the->stack->value.string))
1271 result = 0;
1272 else
1273 result = 1;
1274 break;
1275 default:
1276 result = 1;
1277 break;
1278 }
1279 mxPop();
1280 return result;
1281}
1282
1283/* Arguments and Variables */
1284

Callers 4

fx_structuredCloneFunction · 0.85
fx_Object_freezeFunction · 0.85
_xsTestFunction · 0.85
fxDebugLineFunction · 0.85

Calls 1

c_fpclassifyFunction · 0.85

Tested by

no test coverage detected