code wiki / _hdl_build / nx_fn7b_test.nx
nx_fn7b_test.nx source
↩ module page · 23 lines · 2316 B
1// nx_fn7b_test.nx -- run jQuery factory statement #7 VERBATIM (jQuery.fn object literal) with its real deps.
2import "nx_syscalls.nx"
3import "nx_js_eval.nx"
4func slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
5func cw(s: *u8) -> i64 { sys_write(1,s,slen(s)); return 0 }
6func run1(label: *u8, js: *u8) -> i64 {
7 js_set_rt_dbg(1)
8 let obx: *i64 = sys_mmap(16) as *i64
9 js_run_source_keep_doc(js, slen(js), 0 as *u8, 0, obx)
10 let genv: *i64 = (obx[1]) as *i64
11 cw(label); cw(": " as *u8)
12 if (genv as i64)==0 { cw("NULL\n" as *u8); return 1 }
13 let ub: *u8 = sys_mmap(2048); let t: i64 = js_pending_total(genv)
14 if t==0 { cw("THREW(no fetch)" as *u8) } else { var i: i64=0; while i<t { let ul: i64=js_pending_url(genv,i,ub,2048); if ul>0 { cw(ub); cw(" " as *u8) } i=i+1 } }
15 let ep: i64 = js_rt_errpos_get(); if ep>=0 { cw(" errpos>=0" as *u8) }
16 cw("\n" as *u8); return 0
17}
18func main() -> i64 {
19 run1("EXACT-#7" as *u8, "var oe=[],ae=oe.slice,s=oe.push,t='3.7.1';var ce=function(e,t){return new ce.fn.init(e,t)};ce.fn=ce.prototype={jquery:t,constructor:ce,length:0,toArray:function(){return ae.call(this)},get:function(e){return null==e?ae.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=ce.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return ce.each(this,e)},map:function(n){return this.pushStack(ce.map(this,function(e,t){return n.call(e,t,e)}))},slice:function(){return this.pushStack(ae.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(ce.grep(this,function(e,t){return(t+1)%2}))},odd:function(){return this.pushStack(ce.grep(this,function(e,t){return t%2}))},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(0<=n&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:s,sort:oe.sort,splice:oe.splice};fetch('x/done-'+(typeof ce.fn.eq));" as *u8)
20 run1("just-sort-splice" as *u8, "var oe=[];var f={};f.sort=oe.sort;f.splice=oe.splice;fetch('x/'+(typeof f.sort)+'-'+(typeof f.splice));" as *u8)
21 run1("new-in-ctor-body" as *u8, "var ce=function(e,t){return new ce.fn.init(e,t)};ce.fn={init:function(){}};fetch('x/'+(typeof ce.fn.init));" as *u8)
22 return 0
23}