UNPKG

sai-language

Version:

An object-oriented language designed to afford code comprehension and maintenance. Transpiles in-place to Javascript.

330 lines (329 loc) 7.32 kB
var __context={"name":"Constructs","loader":"SAI.GetSourceFromPaths","path":"../test/Constructs.sai","mtime":"2018-03-07T19:56:16.820Z","fetched":"2018-03-07T20:07:19.139Z"}; var isa = prototype.isa = 'Constructs'; var $bindfail = function(m) { throw new Error("SAI: A call to " + m + " on object " + isa + " has come unbound from any instance of that object. (If this is not in error, mark the declaration of " + m + " as unbound.)"); } prototype.isof['Constructs'] = { version: '0.0.0-unspecified', isa: isa, context: __context }; prototype.__tobelocked = prototype.__tobelocked.concat(["'Execute'", "isa"]); prototype.__tobefrozen = prototype.__tobefrozen.concat(["isof"]); prototype.isof[prototype.isa].inherit = prototype.__inherits = ['Harness']; var $28g = prototype['Execute'] || function() {}; prototype['Execute'] = function(p) { var $_d, $_c, $32, $31, _e, $30, $29, $28, $27, _success, $26, $25, $24, $23, $22, $21, $20, $19, $18, $17, $16, $15, $14, $13, _b, $11, $10, $9, $8, _a, $7, $6, $5, $4, $3, $2, $1, $0, , $ = this['Execute'] ? this : $bindfail('Execute'); { $.Test('if true', function(p) { { if ($0 = (true)) { return (true); } } }); $.Test('unless false', function(p) { { if (!(false)) { return (true); } } }); $.Test('if else', function(p) { { if ($1 = (false)) { return (false); } else { return (true); } return (false); } }); $.Test('unless else', function(p) { { if (!(true)) { return (false); } else { return (true); } return (false); } }); $.Test('if elsif', function(p) { { if ($2 = (false)) { return (false); } else if ($3 = (true)) { return (true); } else { return (false); } return (false); } }); $.Test('if elsunless', function(p) { { if ($4 = (false)) { return (false); } else if (!(false)) { return (true); } return (false); } }); $.Test('unless elsunless', function(p) { { if (!(true)) { return (false); } else if (!(false)) { return (true); } return (false); } }); $.Test('unless elsif', function(p) { { if (!(true)) { return (false); } else if ($5 = (true)) { return (true); } return (false); } }); $.Test('unless elsif else', function(p) { { if (!(true)) { return (false); } else if ($6 = (false)) { return (false); } else { return (true); } return (false); } }); $.Test('if trial', function(p) { { if ($7 = (true)) { return ($7); } } }); $.Test('if trial named', function(p) { { if (_a = (true)) { return (_a); } } }); $.Test('exists true', function(p) { { if (undefined !== ($8 = (false))) { return (true); } return (false); } }); $.Test('exists undefined', function(p) { { if (undefined !== ($9 = (undefined))) { return (false); } return (true); } }); $.Test('exists else', function(p) { { if (undefined !== ($10 = (undefined))) { return (false); } else { return (true); } return (false); } }); $.Match('exists it', 1, function(p) { { if (undefined !== ($11 = (1))) { return ($11); } return (false); } }); $.Match('exists named', 1, function(p) { { if (undefined !== (_b = (1))) { return (_b); } return (false); } }); $.Match('with', 1, function(p) { { _a = { b: 1 }; var $12 = _a; return ($12.b); } }); $.Test('switch case', function(p) { { switch (_a = (2)) { case 1: return (false); break; case 2: return (_a); break; default: return (false); break; } return (false); } }); $.Test('switch multicase', function(p) { { switch ($16 = (2)) { case 1: return (false); break; case 0: case 3: case 2: switch ($13 = (1)) { case 1: case 2: return (true); break; default: return (false); break; } break; default: return (false); break; } return (false); } }); $.Test('switch default', function(p) { { switch ($20 = (2)) { case 1: return (false); break; default: return (true); break; } return (false); } }); $.Test('switch none', function(p) { { switch ($23 = (2)) { case 1: return (false); break; default: ; break; } return (true); } }); $.Test('finally uncaught', function(p) { { try { _a = undefined; } catch ($26) { return (false); } finally { return (true); } return (false); } }); $.Test('finally caught', function(p) { { _success = false; try { _a = undefined; _a.b = 'uh oh'; } catch ($27) { _success = true; } finally { return (_success); } return (false); } }); $.Test('try uncaught', function(p) { { try { _a = undefined; } catch ($28) { return (false); } return (true); } }); $.Test('try caught', function(p) { { try { _a = undefined; _a.b = 'uh oh'; } catch ($29) { return (true); } return (false); } }); $.Test('catch magic', function(p) { { try { _a = undefined; _a.b = 'uh oh'; } catch ($30) { return (($30 !== undefined)); } return (false); } }); $.Test('catch normal', function(p) { { try { _a = undefined; _a.b = 'uh oh'; } catch (_e) { return ((_e !== undefined)); } return (false); } }); $.Match('throw', '1', function(p) { { try { throw new Error('1'); } catch ($31) { return ($31.message); } return (false); } }); $.Test('assert', function(p) { { try { $AI.assert(false); return (false); } catch ($32) { return (true); } return (false); } }); } };