aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMark Miller <erights@gmail.com>2011-09-23 16:21:12 -0700
committerMark Miller <erights@gmail.com>2011-09-23 16:21:12 -0700
commit122550c5dd5e88fe0edaa2de98eb9fee97e81758 (patch)
tree655a6009cdd7a9c95bb657c868dcd9915b204e59 /tools
parent23e84ad9a115d8ec84fd6fa857d51b2076b77f93 (diff)
Merged
Diffstat (limited to 'tools')
-rw-r--r--tools/converter/convert.js67
-rw-r--r--tools/test262.py2
2 files changed, 40 insertions, 29 deletions
diff --git a/tools/converter/convert.js b/tools/converter/convert.js
index 8badc7a09..1ee9ac47e 100644
--- a/tools/converter/convert.js
+++ b/tools/converter/convert.js
@@ -147,7 +147,7 @@
});
}
if (envelopeMatch[3]) {
- envelope.testRecord.strict_only = '';
+ envelope.testRecord.strictOnly = '';
}
envelope.rest = envelopeMatch[4]; // Do not trim
@@ -262,43 +262,44 @@
}
/**
+ * 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
* test262 style properties, that will be assumed by the new test
* runners.
*/
function normalizeProps(testRecord) {
- if (!('strict_only' in testRecord) && testRecord.strict === 1) {
- testRecord.strict_only = '';
+ if (!('strictOnly' in testRecord) && testRecord.strict === 1) {
+ testRecord.strictOnly = '';
}
if (testRecord.strict === 1) {
delete testRecord.strict;
}
if ('strict_mode_negative' in testRecord) {
- if (!('strict_only' in testRecord)) {
- testRecord.strict_only = '';
- }
- if (!('negative' in testRecord)) {
- testRecord.negative = testRecord.strict_mode_negative;
- delete testRecord.strict_mode_negative;
+ if (!('strictOnly' in testRecord)) {
+ testRecord.strictOnly = '';
}
+ 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
- // absent or empty.
- if (!testRecord.negative && 'errortype' in testRecord) {
- 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;
- }
+ transferProp(testRecord, 'errortype', 'negative');
+ transferProp(testRecord, 'assertion', 'description');
+ transferProp(testRecord, 'assertion', 'comment');
}
t262.normalizeProps = normalizeProps;
@@ -352,6 +353,7 @@
delete testRecord.id;
delete testRecord.name;
+ delete testRecord.section;
testRecord.path = toRelPathStr(nextRelPath);
testRecord.header = envelope.header;
testRecord.comment = envelope.comment;
@@ -361,9 +363,10 @@
}
t262.parseTestRecord = parseTestRecord;
- // The known ones will be rendered first, and in this order.
- var KNOWN_PROPS = ['section', 'path', 'description',
- 'strict_only', 'negative'];
+ // If we see any properties other than these after normalization,
+ // we signal an error.
+ var KNOWN_PROPS = ['path', 'description',
+ 'noStrict', 'strictOnly', 'negative'];
/**
* Turns the (assumed) normalized test record into its string form
@@ -395,7 +398,15 @@
}
delete testRecord.comment;
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;
return result;
}
diff --git a/tools/test262.py b/tools/test262.py
index 061c813fb..c3a4792a0 100644
--- a/tools/test262.py
+++ b/tools/test262.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
# Copyright 2009 the Sputnik authors. All rights reserved.
# This code is governed by the BSD license found in the LICENSE file.