Skip to content

Commit

Permalink
Fixing issue with circular references on printing parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ElonVolo committed Sep 17, 2021
1 parent 3ac8e41 commit 4c5e5dc
Show file tree
Hide file tree
Showing 42 changed files with 4,258 additions and 5,175 deletions.
17 changes: 17 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

General things:

Make sure that logitall is installed globally, and run from a directory other than the project.

Testing Items

* Run Unit Tests
* Test all command line parameters
* Test logitall ignore capabilities
* Test on AST-Types, Recast, JSCodeShift
* Test on full angular applications in Chrome.
* Test on NGXAdmin
* Dune Trello
* ionic conference app
* NGXAdmin

9 changes: 6 additions & 3 deletions __testfixtures__/function-anonymous-logparams.output.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
// @ts-ignore
function decycle(u){var f=[],c=[];return function p(o,i){var t,e,n,r=o&&o.toJSON instanceof Function?o.toJSON():o;if(typeof r=="object"&&r!==null){for(t=0;t<f.length;t+=1)if(f[t]===r)return{$ref:c[t]};if(f.push(r),c.push(i),Object.prototype.toString.apply(r)==="[object Array]")for(n=[],t=0;t<r.length;t+=1)n[t]=p(r[t],i+"["+t+"]");else{n={};for(e in r)Object.prototype.hasOwnProperty.call(r,e)&&(n[e]=p(r[e],i+"["+JSON.stringify(e)+"]"))}return n}return r}(u,"$")}

let testLog = function(paramOne, paramTwo) {
console.log(
"[logitall] __testfixtures__/function-anonymous-logparams.input.ts:1:function(paramOne, paramTwo)"
'[logitall] __testfixtures__/function-anonymous-logparams.input.ts:1:function(paramOne, paramTwo)'
);

console.log(
`[logitall] __testfixtures__/function-anonymous-logparams.input.ts:1::param paramOne value:
${JSON.stringify(paramOne)}`
${JSON.stringify(decycle(paramOne))}`
);

console.log(
`[logitall] __testfixtures__/function-anonymous-logparams.input.ts:1::param paramTwo value:
${JSON.stringify(paramTwo)}`
${JSON.stringify(decycle(paramTwo))}`
);
}
4 changes: 2 additions & 2 deletions __testfixtures__/function-anonymous.output.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
let testLog = function() {
console.log("[logitall] __testfixtures__/function-anonymous.input.ts:1:function()");
}
console.log('[logitall] __testfixtures__/function-anonymous.input.ts:1:function()');
}
11 changes: 7 additions & 4 deletions __testfixtures__/function-arrow-logparams.output.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
// @ts-ignore
function decycle(u){var f=[],c=[];return function p(o,i){var t,e,n,r=o&&o.toJSON instanceof Function?o.toJSON():o;if(typeof r=="object"&&r!==null){for(t=0;t<f.length;t+=1)if(f[t]===r)return{$ref:c[t]};if(f.push(r),c.push(i),Object.prototype.toString.apply(r)==="[object Array]")for(n=[],t=0;t<r.length;t+=1)n[t]=p(r[t],i+"["+t+"]");else{n={};for(e in r)Object.prototype.hasOwnProperty.call(r,e)&&(n[e]=p(r[e],i+"["+JSON.stringify(e)+"]"))}return n}return r}(u,"$")}

let testLog = (paramOne, paramTwo) => {
console.log(
"[logitall] __testfixtures__/function-arrow-logparams.input.ts:1:(paramOne, paramTwo) => {}"
'[logitall] __testfixtures__/function-arrow-logparams.input.ts:1:(paramOne, paramTwo) => {}'
);

console.log(
`[logitall] __testfixtures__/function-arrow-logparams.input.ts:1::param paramOne value:
${JSON.stringify(paramOne)}`
${JSON.stringify(decycle(paramOne))}`
);

console.log(
`[logitall] __testfixtures__/function-arrow-logparams.input.ts:1::param paramTwo value:
${JSON.stringify(paramTwo)}`
${JSON.stringify(decycle(paramTwo))}`
);
};
};
2 changes: 1 addition & 1 deletion __testfixtures__/function-arrow.output.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
let testLog = () => {
console.log("[logitall] __testfixtures__/function-arrow.input.ts:1:() => {}");
console.log('[logitall] __testfixtures__/function-arrow.input.ts:1:() => {}');
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default function (options: MyOptions): ResultValue {
console.log(
"[logitall] __testfixtures__/function-declaration-export-default-function.input.ts:1:function(options)"
'[logitall] __testfixtures__/function-declaration-export-default-function.input.ts:1:function(options)'
);
}

11 changes: 7 additions & 4 deletions __testfixtures__/function-declaration-logparams.output.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
// @ts-ignore
function decycle(u){var f=[],c=[];return function p(o,i){var t,e,n,r=o&&o.toJSON instanceof Function?o.toJSON():o;if(typeof r=="object"&&r!==null){for(t=0;t<f.length;t+=1)if(f[t]===r)return{$ref:c[t]};if(f.push(r),c.push(i),Object.prototype.toString.apply(r)==="[object Array]")for(n=[],t=0;t<r.length;t+=1)n[t]=p(r[t],i+"["+t+"]");else{n={};for(e in r)Object.prototype.hasOwnProperty.call(r,e)&&(n[e]=p(r[e],i+"["+JSON.stringify(e)+"]"))}return n}return r}(u,"$")}

function testLog(paramOne, paramTwo) {
console.log(
"[logitall] __testfixtures__/function-declaration-logparams.input.ts:1:testLog(paramOne, paramTwo)"
'[logitall] __testfixtures__/function-declaration-logparams.input.ts:1:testLog(paramOne, paramTwo)'
);

console.log(
`[logitall] __testfixtures__/function-declaration-logparams.input.ts:1:testLog:param paramOne value:
${JSON.stringify(paramOne)}`
${JSON.stringify(decycle(paramOne))}`
);

console.log(
`[logitall] __testfixtures__/function-declaration-logparams.input.ts:1:testLog:param paramTwo value:
${JSON.stringify(paramTwo)}`
${JSON.stringify(decycle(paramTwo))}`
);
}
}
2 changes: 1 addition & 1 deletion __testfixtures__/function-declaration.output.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
function testLog() {
console.log("[logitall] __testfixtures__/function-declaration.input.ts:1:testLog()");
console.log('[logitall] __testfixtures__/function-declaration.input.ts:1:testLog()');
}
8 changes: 6 additions & 2 deletions __testfixtures__/function-rest-parameter.output.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@

// @ts-ignore
function decycle(u){var f=[],c=[];return function p(o,i){var t,e,n,r=o&&o.toJSON instanceof Function?o.toJSON():o;if(typeof r=="object"&&r!==null){for(t=0;t<f.length;t+=1)if(f[t]===r)return{$ref:c[t]};if(f.push(r),c.push(i),Object.prototype.toString.apply(r)==="[object Array]")for(n=[],t=0;t<r.length;t+=1)n[t]=p(r[t],i+"["+t+"]");else{n={};for(e in r)Object.prototype.hasOwnProperty.call(r,e)&&(n[e]=p(r[e],i+"["+JSON.stringify(e)+"]"))}return n}return r}(u,"$")}

function doStuff(...myArray) {
console.log(
"[logitall] __testfixtures__/function-rest-parameter.input.ts:1:doStuff(...myArray)"
'[logitall] __testfixtures__/function-rest-parameter.input.ts:1:doStuff(...myArray)'
);

console.log(
`[logitall] __testfixtures__/function-rest-parameter.input.ts:1:doStuff:param myArray value:
${JSON.stringify(myArray)}`
${JSON.stringify(decycle(myArray))}`
);

let stuff = 'things';
Expand Down
4 changes: 4 additions & 0 deletions __testfixtures__/function-return-nonbrace-for-in.input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const object = { a: 1, b: 2, c: 3 };

for (const property in object)
return 5;
4 changes: 4 additions & 0 deletions __testfixtures__/function-return-nonbrace-for-in.output.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const object = { a: 1, b: 2, c: 3 };

for (const property in object)
return 5;
4 changes: 4 additions & 0 deletions __testfixtures__/function-return-nonbrace-for-of.input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const array1 = ['a', 'b', 'c'];

for (const element of array1)
console.log(element);
4 changes: 4 additions & 0 deletions __testfixtures__/function-return-nonbrace-for-of.output.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const array1 = ['a', 'b', 'c'];

for (const element of array1)
console.log(element);
4 changes: 2 additions & 2 deletions __testfixtures__/function-return.output.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function bunny() {
console.log("[logitall] __testfixtures__/function-return.input.ts:1:bunny()");
console.log("[logitall] __testfixtures__/function-return.input.ts:2");
console.log('[logitall] __testfixtures__/function-return.input.ts:1:bunny()');
console.log('[logitall] __testfixtures__/function-return.input.ts:2');
return 'bubba';
}
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
// @ts-ignore
function decycle(u){var f=[],c=[];return function p(o,i){var t,e,n,r=o&&o.toJSON instanceof Function?o.toJSON():o;if(typeof r=="object"&&r!==null){for(t=0;t<f.length;t+=1)if(f[t]===r)return{$ref:c[t]};if(f.push(r),c.push(i),Object.prototype.toString.apply(r)==="[object Array]")for(n=[],t=0;t<r.length;t+=1)n[t]=p(r[t],i+"["+t+"]");else{n={};for(e in r)Object.prototype.hasOwnProperty.call(r,e)&&(n[e]=p(r[e],i+"["+JSON.stringify(e)+"]"))}return n}return r}(u,"$")}

class BaseClass {

public items:number[];

constructor(private paramOne:number, private paramTwo:number) {
console.log(
"[logitall] __testfixtures__/method-constructor-logparams-access-modifier.input.ts:5:constructor()"
'[logitall] __testfixtures__/method-constructor-logparams-access-modifier.input.ts:5:constructor()'
);

console.log(
`[logitall] __testfixtures__/method-constructor-logparams-access-modifier.input.ts:5::param paramOne value:
${JSON.stringify(paramOne)}`
${JSON.stringify(decycle(paramOne))}`
);

console.log(
`[logitall] __testfixtures__/method-constructor-logparams-access-modifier.input.ts:5::param paramTwo value:
${JSON.stringify(paramTwo)}`
${JSON.stringify(decycle(paramTwo))}`
);

console.log(
"[logitall] __testfixtures__/method-constructor-logparams-access-modifier.input.ts:6"
'[logitall] __testfixtures__/method-constructor-logparams-access-modifier.input.ts:6'
);

this.items = [paramOne, paramTwo];
}

mathOperation(): number {
console.log(
"[logitall] __testfixtures__/method-constructor-logparams-access-modifier.input.ts:9:mathOperation()"
'[logitall] __testfixtures__/method-constructor-logparams-access-modifier.input.ts:9:mathOperation()'
);

console.log(
"[logitall] __testfixtures__/method-constructor-logparams-access-modifier.input.ts:10"
'[logitall] __testfixtures__/method-constructor-logparams-access-modifier.input.ts:10'
);

return this.items[0] + this.items[1];
Expand All @@ -43,17 +46,17 @@ class Subclass extends BaseClass {
super(paramOne, paramTwo);

console.log(
"[logitall] __testfixtures__/method-constructor-logparams-access-modifier.input.ts:16:constructor()"
'[logitall] __testfixtures__/method-constructor-logparams-access-modifier.input.ts:16:constructor()'
);
}

mathOperation(): number {
console.log(
"[logitall] __testfixtures__/method-constructor-logparams-access-modifier.input.ts:20:mathOperation()"
'[logitall] __testfixtures__/method-constructor-logparams-access-modifier.input.ts:20:mathOperation()'
);

console.log(
"[logitall] __testfixtures__/method-constructor-logparams-access-modifier.input.ts:21"
'[logitall] __testfixtures__/method-constructor-logparams-access-modifier.input.ts:21'
);

return this.items[0] * this.items[1];
Expand Down
2 changes: 1 addition & 1 deletion __testfixtures__/method-constructor-logparams.input.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class BaseClass {

public items:number[];

constructor(paramOne:number, paramTwo:number) {
Expand Down
23 changes: 13 additions & 10 deletions __testfixtures__/method-constructor-logparams.output.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
// @ts-ignore
function decycle(u){var f=[],c=[];return function p(o,i){var t,e,n,r=o&&o.toJSON instanceof Function?o.toJSON():o;if(typeof r=="object"&&r!==null){for(t=0;t<f.length;t+=1)if(f[t]===r)return{$ref:c[t]};if(f.push(r),c.push(i),Object.prototype.toString.apply(r)==="[object Array]")for(n=[],t=0;t<r.length;t+=1)n[t]=p(r[t],i+"["+t+"]");else{n={};for(e in r)Object.prototype.hasOwnProperty.call(r,e)&&(n[e]=p(r[e],i+"["+JSON.stringify(e)+"]"))}return n}return r}(u,"$")}

class BaseClass {

public items:number[];

constructor(paramOne:number, paramTwo:number) {
console.log(
"[logitall] __testfixtures__/method-constructor-logparams.input.ts:5:constructor()"
'[logitall] __testfixtures__/method-constructor-logparams.input.ts:5:constructor()'
);

console.log(
`[logitall] __testfixtures__/method-constructor-logparams.input.ts:5::param paramOne value:
${JSON.stringify(paramOne)}`
${JSON.stringify(decycle(paramOne))}`
);

console.log(
`[logitall] __testfixtures__/method-constructor-logparams.input.ts:5::param paramTwo value:
${JSON.stringify(paramTwo)}`
${JSON.stringify(decycle(paramTwo))}`
);

console.log("[logitall] __testfixtures__/method-constructor-logparams.input.ts:6");
console.log('[logitall] __testfixtures__/method-constructor-logparams.input.ts:6');
this.items = [paramOne, paramTwo];
}

mathOperation(): number {
console.log(
"[logitall] __testfixtures__/method-constructor-logparams.input.ts:9:mathOperation()"
'[logitall] __testfixtures__/method-constructor-logparams.input.ts:9:mathOperation()'
);

console.log("[logitall] __testfixtures__/method-constructor-logparams.input.ts:10");
console.log('[logitall] __testfixtures__/method-constructor-logparams.input.ts:10');
return this.items[0] + this.items[1];
}
}
Expand All @@ -37,16 +40,16 @@ class Subclass extends BaseClass {
super(paramOne, paramTwo);

console.log(
"[logitall] __testfixtures__/method-constructor-logparams.input.ts:16:constructor()"
'[logitall] __testfixtures__/method-constructor-logparams.input.ts:16:constructor()'
);
}

mathOperation(): number {
console.log(
"[logitall] __testfixtures__/method-constructor-logparams.input.ts:20:mathOperation()"
'[logitall] __testfixtures__/method-constructor-logparams.input.ts:20:mathOperation()'
);

console.log("[logitall] __testfixtures__/method-constructor-logparams.input.ts:21");
console.log('[logitall] __testfixtures__/method-constructor-logparams.input.ts:21');
return this.items[0] * this.items[1];
}
}
11 changes: 6 additions & 5 deletions __testfixtures__/method-constructor.output.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@

class BaseClass {

public stuff:string;

constructor() {
console.log("[logitall] __testfixtures__/method-constructor.input.ts:5:constructor()");
console.log("[logitall] __testfixtures__/method-constructor.input.ts:6");
console.log('[logitall] __testfixtures__/method-constructor.input.ts:5:constructor()');
console.log('[logitall] __testfixtures__/method-constructor.input.ts:6');
this.stuff = "things"
}

doStuff() {
console.log("[logitall] __testfixtures__/method-constructor.input.ts:9:doStuff()");
console.log('[logitall] __testfixtures__/method-constructor.input.ts:9:doStuff()');
let matter = this.stuff;
}
}
Expand All @@ -21,10 +22,10 @@ class Subclass extends BaseClass {
super();

console.log(
"[logitall] __testfixtures__/method-constructor.input.ts:17:constructor()"
'[logitall] __testfixtures__/method-constructor.input.ts:17:constructor()'
);

console.log("[logitall] __testfixtures__/method-constructor.input.ts:19");
console.log('[logitall] __testfixtures__/method-constructor.input.ts:19');
this.items = ["ThingOne", "ThingTwo"];
}
}
Expand Down
11 changes: 7 additions & 4 deletions __testfixtures__/method-instance-logparams.output.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
// @ts-ignore
function decycle(u){var f=[],c=[];return function p(o,i){var t,e,n,r=o&&o.toJSON instanceof Function?o.toJSON():o;if(typeof r=="object"&&r!==null){for(t=0;t<f.length;t+=1)if(f[t]===r)return{$ref:c[t]};if(f.push(r),c.push(i),Object.prototype.toString.apply(r)==="[object Array]")for(n=[],t=0;t<r.length;t+=1)n[t]=p(r[t],i+"["+t+"]");else{n={};for(e in r)Object.prototype.hasOwnProperty.call(r,e)&&(n[e]=p(r[e],i+"["+JSON.stringify(e)+"]"))}return n}return r}(u,"$")}

class TestInstanceMethodClass {
testlog(paramOne:number, paramTwo: number): number {
console.log(
"[logitall] __testfixtures__/method-instance-logparams.input.ts:2:testlog()"
'[logitall] __testfixtures__/method-instance-logparams.input.ts:2:testlog()'
);

console.log(
`[logitall] __testfixtures__/method-instance-logparams.input.ts:2::param paramOne value:
${JSON.stringify(paramOne)}`
${JSON.stringify(decycle(paramOne))}`
);

console.log(
`[logitall] __testfixtures__/method-instance-logparams.input.ts:2::param paramTwo value:
${JSON.stringify(paramTwo)}`
${JSON.stringify(decycle(paramTwo))}`
);

const total:number = paramOne + paramTwo;
console.log("[logitall] __testfixtures__/method-instance-logparams.input.ts:4");
console.log('[logitall] __testfixtures__/method-instance-logparams.input.ts:4');
return total;
}
}
4 changes: 2 additions & 2 deletions __testfixtures__/method-instance.output.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class TestInstanceMethodClass {
testlog(paramOne:number, paramTwo: number): number {
console.log("[logitall] __testfixtures__/method-instance.input.ts:2:testlog()");
console.log('[logitall] __testfixtures__/method-instance.input.ts:2:testlog()');
const total:number = paramOne + paramTwo;
console.log("[logitall] __testfixtures__/method-instance.input.ts:4");
console.log('[logitall] __testfixtures__/method-instance.input.ts:4');
return total;
}
}
Loading

0 comments on commit 4c5e5dc

Please sign in to comment.