123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341 |
-
- var assert = require('chai').assert
- const util = require('util');
- var utils = require("../bbhverse-pb-wip/utils")
-
- var js = utils.js;
- const proxiedDescriptor = js.proxiedDescriptor;
- const Ref = js.Ref;
- const valueBackedAccessor = js.valueBackedAccessor;
-
-
- var vValue = js.vValue;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- console.dir(Reflect.ownKeys(Reflect));
-
-
-
- (()=>{
- utils.js.typeInstances.forEach((instance)=>{
- try {
- new Proxy(instance,{})
- js.proxyable.push(js.nativeType(instance))
- }
- catch(e){
- js.nonproxyable.push(js.nativeType(instance))
-
-
- }
- })
- return;
- })()
- console.dir('console.dir(js.proxyable)');
- console.dir(js.proxyable)
- console.dir('console.dir(js.nonproxyable)');
- console.dir(js.nonproxyable);
-
-
-
- var vstore = '';
- var r = {}
- Object.defineProperty(r, 'p',{ get : function(){ return 'u got me : ' + vstore }, set : function(v){ vstore = v}, enumerable:true })
- console.dir(r)
- console.dir('***************-------- ')
- r.p = 'Pvalue'
- var ref = js.Ref.create(r, 'p')
- console.dir(ref)
- ref.y ='sadasdf'
- console.dir(ref)
- ref.assign('u set me')
- ref.x = 'asd'
- console.dir(ref)
- console.dir(r)
-
-
- r = {}
- ref = js.Ref.create(r, 'p')
- console.dir('***************-------- ')
- console.dir(ref)
- console.dir(typeof(ref))
- r.p = 'initialP'
- console.dir(ref)
- console.dir(typeof(ref))
-
-
-
-
-
-
-
-
- r = { p : 'p'}
- ref = js.Ref.create(r, 'p')
- console.dir('***************-------- ')
- console.dir(ref)
- console.dir(typeof(ref))
- console.dir(typeof(new String('abc')))
-
-
-
- ref.assign("P")
- console.dir(ref)
-
- console.dir(r)
- ref.assign("PP")
-
- console.dir(ref)
- console.dir(Object.prototype.toString.call(ref))
- console.dir(new String('asdfasdf'))
- console.dir(Object.prototype.toString.call(new String('asdfasdf')))
-
- console.dir(r)
-
- r.p = "original replaced"
- console.dir(ref)
- console.dir(r)
-
-
-
- console.dir('ref.x')
- console.dir(ref.x)
- ref.x = 'X';
- console.dir(ref.x)
- console.dir(ref)
- console.dir(r)
- console.dir(ref.substring(2,5))
-
- r.p = 'x after pchanged'
-
- console.dir(ref.x)
- console.dir(ref)
- console.dir(r)
-
- ref.assign(new String('ref.assign'));
- console.dir(ref.x)
- console.dir(ref)
- console.dir(r)
-
- var ns = new String('sdsd')
- console.dir(ns)
- ns.x = 'X'
- console.dir(ns)
-
-
-
-
-
-
-
-
-
-
- var o = js.Versioned.create()
-
-
-
-
-
-
- o.assign(new String('ddd'));
- console.dir('console.dir(o).......................')
-
- console.dir(o)
- console.dir('ssss' + o)
- o.x = 'xtttt'
- console.dir(o)
- console.dir('sssfff : ' + o)
- console.dir('console.dir(o).......................')
-
- o.assign(new Number(5));
- console.dir('console.dir(o).......................')
- console.dir(o)
- console.dir('ssss' + o)
- console.dir(3 + o)
- console.dir('console.dir(o).......................')
-
-
-
- o.assign(new Boolean(true));
- console.dir('console.dir(o).......................')
- console.dir('ssss' + true)
-
- console.dir(o)
- console.dir('ssss' + o)
- console.dir(3 + o)
- console.dir(3 + true)
- console.dir('console.dir(o).......................')
-
-
-
- o = js.Versioned.create(o)
- var x = { a: 5 }
- o.vV = x;
-
- console.dir(o.vV)
- console.dir('console.dir(o).......................')
- console.dir(o)
- console.dir('console.dir(o).......................')
- console.dir(o.vV)
-
- console.log(assert.deepEqual(o.vV, x));
-
- console.log(assert.strictEqual(o.vV.current, x, 'but is not'));
- x = { a: 4 }
- o.vV.revision = x
- console.dir(o.vV)
- assert.deepEqual(o.vV, x);
-
-
-
- assert.strictEqual(o.vV.current, x), 'but is not';
-
-
- o = js.Versioned.create()
- x = { a: 5 }
- o.vV = x;
-
- console.dir(o.vV)
-
- assert.deepEqual(o.vV, x, 'o.vV and { a : 5} found equal');
-
- x = { a: 4 }
- o.vV = x
- console.dir(o.vV)
- assert.deepEqual(o.vV, x);
-
-
-
- var ten = { g : "10" }
-
- var o1 = js.Versioned.create();
-
-
-
-
- console.log('console.log(cloned.vV)')
- console.log(o1.vV)
- console.log(Object.prototype.toString.call(o1.vV))
- console.log('---------------------------------------------')
- console.log('console.dir(o1.vV)')
- console.dir(o1.vV)
- console.log(Object.prototype.toString.call(o1.vV))
-
- console.log('---------------------------------------------')
- console.log('util.inspect(o1.vV)')
- console.log(util.inspect(o1.vV))
- console.log(Object.prototype.toString.call(o1.vV))
- console.log('---------------------------------------------')
-
- o1.vV = { d : 7 }
-
- console.dir(o1.vV)
- o1.vV = { e : 8 }
- console.dir(o1.vV)
- o1.vV = { f : "9 Nine" }
- console.dir(o1.vV)
- debugger
- o1.vV = ten
- var a = o1.vV;
- o1.vV = ten
-
-
-
- console.dir(o1.vV)
- console.dir(o1.vV.g)
- assert.deepEqual(o1.vV, ten);
- assert.strictEqual(o1.vV, a);
-
- console.dir('(ten == (+o1.vV))')
-
- console.dir((ten == o1.vV))
- console.dir((ten === o1.vV))
-
-
- console.dir('(o1.vV.valueOf() === ten)')
- console.dir((o1.vV.valueOf() === ten))
- assert.strictEqual(o1.vV.valueOf(), ten);
- assert.strictEqual(js.Proxied.getTarget(o1.vV), ten);
-
-
-
- var c = proxiedDescriptor.create(o1, 'dD', null, proxiedDescriptor.current);
- Object.defineProperty(o1, 'dD', c);
- var dD = Object.getOwnPropertyDescriptor(o1, "dD");
- console.dir('console.dir(c === dD)')
- console.dir(c === dD)
- console.log((dD.get === c.get) + ' ' + 'dD.get === c.get')
-
-
- var d = Object.getOwnPropertyDescriptor(o1, "vV");
- console.dir(d);
- console.dir('switching proxiedDescriptor type to composite revision')
- proxiedDescriptor.switchTo(d, proxiedDescriptor['composite revision'])
- o1.vV = { eleven : '11'}
- console.dir('o1.vV')
- console.dir(o1.vV)
- assert.deepEqual(o1.vV, { g : "10", eleven : '11' } );
-
-
-
- var vV = o1.vV;
-
- vV.revision = { "12" : 12 }
- console.dir(vV);
- console.dir(vV.composite);
- assert.deepEqual(vV, o1.vV );
-
- var v = ['a', 'b', 'c'];
- var b = v.valueOf()
- console.log(v===b)
- console.dir(b)
-
-
- var proxT = { a : 'A', b : { bv : 'bv'}, c : ['e', 4, { x : 'x'}]}
- var prox = js.mutableProxy.create(proxT)
- prox = js.mutableProxy.create(prox)
- prox = js.mutableProxy.create(prox)
- console.dir(prox)
- console.dir(proxT === prox)
- prox = js.mutableProxy.create(prox)
- prox = js.mutableProxy.create(prox)
- prox = js.mutableProxy.create(prox)
- console.dir(js.dereference(prox))
- console.dir(proxT === js.dereference(prox))
-
-
- elxr = utils.elxr
-
-
-
-
-
-
-
-
-
-
- console.dir(elxr.bitIndices)
- console.dir(elxr.toBitString(elxr.bitIndices[31]))
- console.dir(elxr.toBitString(elxr.insertBitsForMask(16, 6)))
-
- var nwM = elxr.nextWithMask(6)
- console.dir(elxr.toBitString(nwM.next().value))
- console.dir(elxr.toBitString(nwM.next().value))
- console.dir(elxr.toBitString(nwM.next().value))
- console.dir(elxr.toBitString(nwM.next().value))
|