Bug 1286864 - Reps: array should show how many items is not displayed. r=odvarko

This commit is contained in:
Dalimil Hajek 2016-07-27 00:27:00 +02:00
parent eab2b0ad2c
commit 3fdef28070
8 changed files with 20 additions and 23 deletions

View File

@ -32,7 +32,7 @@ define(function (require, exports, module) {
let items = [];
let delim;
for (let i = 0; i < array.length && i <= max; i++) {
for (let i = 0; i < array.length && i < max; i++) {
try {
let value = array[i];
@ -61,14 +61,12 @@ define(function (require, exports, module) {
}
if (array.length > max) {
items.pop();
let objectLink = this.props.objectLink || DOM.span;
items.push(Caption({
key: "more",
object: objectLink({
object: this.props.object
}, "more…")
}, (array.length - max) + " more…")
}));
}

View File

@ -59,7 +59,7 @@ define(function (require, exports, module) {
let delim;
let provider = this.props.provider;
for (let i = 0; i < array.length && i <= max; i++) {
for (let i = 0; i < array.length && i < max; i++) {
try {
let itemGrip = array[i];
let value = provider ? provider.getValue(itemGrip) : itemGrip;
@ -89,13 +89,12 @@ define(function (require, exports, module) {
}
if (array.length > max) {
items.pop();
let objectLink = this.props.objectLink || span;
items.push(Caption({
key: "more",
object: objectLink({
object: this.props.object
}, "more…")
}, (grip.preview.length - max) + " more…")
}));
}

View File

@ -79,7 +79,7 @@ define(function (require, exports, module) {
key: "more",
object: objectLink({
object: object
}, "more…")
}, ((object ? object.ownPropertyLength : 0) - max) + " more…")
}));
} else if (props.length > 0) {
// Remove the last comma.

View File

@ -78,7 +78,7 @@ define(function (require, exports, module) {
key: "more",
object: objectLink({
object: object
}, "more…")
}, (Object.keys(object).length - max) + " more…")
}));
} else if (props.length > 0) {
// Remove the last comma.

View File

@ -107,7 +107,7 @@ window.onload = Task.async(function* () {
function testMoreThanShortMaxProps() {
const stub = Array(maxLength.short + 1).fill("foo");
const defaultShortOutput = `[${Array(maxLength.short).fill("\"foo\"").join(", ")}, more…]`;
const defaultShortOutput = `[${Array(maxLength.short).fill("\"foo\"").join(", ")}, 1 more…]`;
const modeTests = [
{
@ -133,8 +133,8 @@ window.onload = Task.async(function* () {
function testMoreThanLongMaxProps() {
const stub = Array(maxLength.long + 1).fill("foo");
const defaultShortOutput = `[${Array(maxLength.short).fill("\"foo\"").join(", ")}, more…]`;
const defaultLongOutput = `[${Array(maxLength.long).fill("\"foo\"").join(", ")}, more…]`;
const defaultShortOutput = `[${Array(maxLength.short).fill("\"foo\"").join(", ")}, ${maxLength.long + 1 - maxLength.short} more…]`;
const defaultLongOutput = `[${Array(maxLength.long).fill("\"foo\"").join(", ")}, 1 more…]`;
const modeTests = [
{
@ -194,7 +194,7 @@ window.onload = Task.async(function* () {
p4: "s4"
}
];
const defaultOutput = `[Object{p1: "s1", p3: "s3", p4: "s4", more…}]`;
const defaultOutput = `[Object{p1: "s1", p3: "s3", p4: "s4", 1 more…}]`;
const modeTests = [
{
@ -227,7 +227,7 @@ window.onload = Task.async(function* () {
const defaultOutput = `["a", "b", "c", "d", "e", "f", "g", "h", "i", "j",` +
` "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",` +
` "u", "v", "w", "x", "y", "z"]`;
const shortOutput = `["a", "b", "c", more…]`;
const shortOutput = `["a", "b", "c", 23 more…]`;
const modeTests = [
{

View File

@ -106,7 +106,7 @@ window.onload = Task.async(function* () {
// Test array = `["test string"…] //4 items`
const testName = "testMoreThanShortMaxProps";
const defaultOutput = `Array[${Array(maxLength.short).fill("\"test string\"").join(", ")}, more…]`;
const defaultOutput = `Array[${Array(maxLength.short).fill("\"test string\"").join(", ")}, 1 more…]`;
const modeTests = [
{
@ -134,8 +134,8 @@ window.onload = Task.async(function* () {
// Test array = `["test string"…] //301 items`
const testName = "testMoreThanLongMaxProps";
const defaultShortOutput = `Array[${Array(maxLength.short).fill("\"test string\"").join(", ")}, more…]`;
const defaultLongOutput = `Array[${Array(maxLength.long).fill("\"test string\"").join(", ")}, more…]`;
const defaultShortOutput = `Array[${Array(maxLength.short).fill("\"test string\"").join(", ")}, ${maxLength.long + 1 - maxLength.short} more…]`;
const defaultLongOutput = `Array[${Array(maxLength.long).fill("\"test string\"").join(", ")}, 1 more…]`;
const modeTests = [
{

View File

@ -100,10 +100,10 @@ window.onload = Task.async(function* () {
}
function testMoreThanMaxProps() {
// Test object = `{p0: "0", p1: "1", p2: "2", …, p101: "101"}`
// Test object = `{p0: "0", p1: "1", p2: "2", …, p100: "100"}`
const testName = "testMoreThanMaxProps";
const defaultOutput = `Object {p0: "0", p1: "1", p2: "2", more…}`;
const defaultOutput = `Object {p0: "0", p1: "1", p2: "2", 98 more…}`;
// Generate string with 100 properties, which is the max limit
// for 'long' mode.
@ -112,7 +112,7 @@ window.onload = Task.async(function* () {
props += "p" + i + ": \"" + i + "\", ";
}
const longOutput = `Object {${props}more…}`;
const longOutput = `Object {${props}1 more…}`;
const modeTests = [
{
@ -140,7 +140,7 @@ window.onload = Task.async(function* () {
// Test object: `{a: undefined, b: undefined, c: "c", d: 1}`
// @TODO This is not how we actually want the preview to be output.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1276376
const expectedOutput = `Object {a: undefined, b: undefined, c: "c", more…}`;
const expectedOutput = `Object {a: undefined, b: undefined, c: "c", 1 more…}`;
}
function testNestedObject() {

View File

@ -101,7 +101,7 @@ window.onload = Task.async(function* () {
for (let i = 0; i<100; i++) {
stub[`p${i}`] = i
}
const defaultOutput = `Object{p0: 0, p1: 1, p2: 2, more…}`;
const defaultOutput = `Object{p0: 0, p1: 1, p2: 2, 97 more…}`;
const modeTests = [
{
@ -127,7 +127,7 @@ window.onload = Task.async(function* () {
function testUninterestingProps() {
const stub = {a:undefined, b:undefined, c:"c", d:0};
const defaultOutput = `Object{c: "c", d: 0, a: undefined, more…}`;
const defaultOutput = `Object{c: "c", d: 0, a: undefined, 1 more…}`;
const modeTests = [
{