This commit is contained in:
Mark Miller 2011-09-23 16:21:12 -07:00
parent 23e84ad9a1
commit 122550c5dd
2 changed files with 40 additions and 29 deletions

View File

@ -147,7 +147,7 @@
}); });
} }
if (envelopeMatch[3]) { if (envelopeMatch[3]) {
envelope.testRecord.strict_only = ''; envelope.testRecord.strictOnly = '';
} }
envelope.rest = envelopeMatch[4]; // Do not trim envelope.rest = envelopeMatch[4]; // Do not trim
@ -261,44 +261,45 @@
return testRecord; return testRecord;
} }
/**
* If record[toName] is absent or empty and record[fromName] is
* present, whether empty or not, then set record[toName] to the
* current value of record[fromName] and delete record[fromName]
*/
function transferProp(record, fromName, toName) {
// Note that record[toName] is falsy whether toName is absent or
// empty
if (!record[toName] && fromName in record) {
record[toName] = record[fromName];
delete record[fromName];
}
}
/** /**
* Normalizes the properties of testRecord to be the canonical * Normalizes the properties of testRecord to be the canonical
* test262 style properties, that will be assumed by the new test * test262 style properties, that will be assumed by the new test
* runners. * runners.
*/ */
function normalizeProps(testRecord) { function normalizeProps(testRecord) {
if (!('strict_only' in testRecord) && testRecord.strict === 1) { if (!('strictOnly' in testRecord) && testRecord.strict === 1) {
testRecord.strict_only = ''; testRecord.strictOnly = '';
} }
if (testRecord.strict === 1) { if (testRecord.strict === 1) {
delete testRecord.strict; delete testRecord.strict;
} }
if ('strict_mode_negative' in testRecord) { if ('strict_mode_negative' in testRecord) {
if (!('strict_only' in testRecord)) { if (!('strictOnly' in testRecord)) {
testRecord.strict_only = ''; testRecord.strictOnly = '';
}
if (!('negative' in testRecord)) {
testRecord.negative = testRecord.strict_mode_negative;
delete testRecord.strict_mode_negative;
} }
transferProp(testRecord, 'strict_mode_negative', 'negative');
} }
transferProp(testRecord, 'strict_only', 'strictOnly');
transferProp(testRecord, 'non_strict_only', 'noStrict');
// Note that testRecord.negative is falsy whether negative is transferProp(testRecord, 'errortype', 'negative');
// absent or empty. transferProp(testRecord, 'assertion', 'description');
if (!testRecord.negative && 'errortype' in testRecord) { transferProp(testRecord, 'assertion', 'comment');
testRecord.negative = testRecord.errortype;
delete testRecord.errortype;
}
if (!testRecord.description && testRecord.assertion) {
testRecord.description = testRecord.assertion;
delete testRecord.assertion;
}
if (!testRecord.comment && testRecord.assertion) {
testRecord.comment = testRecord.assertion;
delete testRecord.assertion;
}
} }
t262.normalizeProps = normalizeProps; t262.normalizeProps = normalizeProps;
@ -352,6 +353,7 @@
delete testRecord.id; delete testRecord.id;
delete testRecord.name; delete testRecord.name;
delete testRecord.section;
testRecord.path = toRelPathStr(nextRelPath); testRecord.path = toRelPathStr(nextRelPath);
testRecord.header = envelope.header; testRecord.header = envelope.header;
testRecord.comment = envelope.comment; testRecord.comment = envelope.comment;
@ -361,9 +363,10 @@
} }
t262.parseTestRecord = parseTestRecord; t262.parseTestRecord = parseTestRecord;
// The known ones will be rendered first, and in this order. // If we see any properties other than these after normalization,
var KNOWN_PROPS = ['section', 'path', 'description', // we signal an error.
'strict_only', 'negative']; var KNOWN_PROPS = ['path', 'description',
'noStrict', 'strictOnly', 'negative'];
/** /**
* Turns the (assumed) normalized test record into its string form * Turns the (assumed) normalized test record into its string form
@ -395,7 +398,15 @@
} }
delete testRecord.comment; delete testRecord.comment;
forEach(KNOWN_PROPS, addProp); forEach(KNOWN_PROPS, addProp);
forEach(keys(testRecord), addProp);
var remaining = keys(testRecord);
if (remaining.length >= 1) {
// If we wanted to preserve unrecognized properties, we'd
// uncomment the following and comment out the next
//forEach(remaining, addProp);
throw new Error('unrecognized: ' + remaining);
}
result += ' */\n\n' + test; result += ' */\n\n' + test;
return result; return result;
} }

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/env python
# Copyright 2009 the Sputnik authors. All rights reserved. # Copyright 2009 the Sputnik authors. All rights reserved.
# This code is governed by the BSD license found in the LICENSE file. # This code is governed by the BSD license found in the LICENSE file.