Skip to content

Commit

Permalink
Debug test
Browse files Browse the repository at this point in the history
  • Loading branch information
Drieger committed Jan 30, 2019
1 parent f3ab09e commit 240cbbb
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 9 deletions.
62 changes: 62 additions & 0 deletions test/fixtures/scan-scenario.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
'use strict';

const common = require('../common');

const zlib = require('zlib');

let outerVar = 'outer variable';

exports.holder = {};

function makeThin(a, b) {
var str = a + b;
var obj = {};
obj[str]; // Turn the cons string into a thin string.
return str;
}

function closure() {

function Class() {
this.x = 1;
this.y = 123.456;

this.hashmap = {};
}


Class.prototype.method = function method() {
throw new Error('Uncaught');
};

const c = new Class();


let scopedVar = 'scoped value';
let scopedAPI = zlib.createDeflate()._handle;
let scopedArray = [ 0, scopedAPI ];

exports.holder = scopedAPI;

c.hashmap.scoped = function name() {
return scopedVar + outerVar + scopedAPI + scopedArray;
};

function Class_B() {
this.my_class_b = "Class B";
}

function Class_C(class_b_array) {
this.arr = class_b_array;
this.my_class_c = "My Class C";
}

const arr = new Array();
for(let i=0; i < 10; i++) arr.push(new Class_B());

let classC = new Class_C(arr);

c.method();
}

closure();
19 changes: 10 additions & 9 deletions test/plugin/scan-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tape('v8 findrefs and friends', (t) => {
test(process.env.LLNODE_NODE_EXE, process.env.LLNODE_CORE, t);
} else {
common.saveCore({
scenario: 'inspect-scenario.js'
scenario: 'scan-scenario.js'
}, (err) => {
t.error(err);
t.ok(true, 'Saved core');
Expand All @@ -32,6 +32,7 @@ function test(executable, core, t) {
sess.send('version');
});


sess.linesUntil(versionMark, (err, lines) => {
t.error(err);
t.ok(/\d+ Class/.test(lines.join('\n')), 'Class should be in findjsobjects');
Expand Down Expand Up @@ -110,6 +111,14 @@ function test(executable, core, t) {
sess.linesUntil(versionMark, (err, lines) => {
t.error(err);
t.ok(/(0x[0-9a-f]+): Class_C\.my_class_c=(0x[0-9a-f]+)/.test(lines.join('\n')), 'Should find class C with property');
sess.send('v8 findrefs -r -n my_class_b');
sess.send('version');
});

// Test for -r -n
sess.linesUntil(versionMark, (err, lines) => {
t.error(err);
t.ok(/Class_C\.arr/.test(lines.join('\n')), 'Should find parent reference with -r -n' );
sess.send('v8 findrefs -s "My Class C"');
sess.send('version');
});
Expand All @@ -126,14 +135,6 @@ function test(executable, core, t) {
sess.linesUntil(versionMark, (err, lines) => {
t.error(err);
t.ok(/Class_C\.arr/.test(lines.join('\n')), 'Should find parent reference with -r -s' );
sess.send('v8 findrefs -r -n "name"');
sess.send('version');
});

// Test for -r -n
sess.linesUntil(versionMark, (err, lines) => {
t.error(err);
t.ok(/Class_C\.arr/.test(lines.join('\n')), 'Should find parent reference with -r -n' );
sess.send('v8 findjsinstances Zlib');
sess.send('version');
});
Expand Down

0 comments on commit 240cbbb

Please sign in to comment.