Add experiment support to gentest

Summary:
This diff does two things
- Clean up some of the generated code making the files smaller.
- Add experiment support to generated tests allowing us to use gentest for things still being experimented with such as more compliant flex-basis behavior.

Reviewed By: gkassabli

Differential Revision: D4226734

fbshipit-source-id: 2cc1471c21883e8e326f16e7a8bb1a3657acd84b
This commit is contained in:
Emil Sjolander
2016-11-23 11:12:51 -08:00
committed by Facebook Github Bot
parent a0d560a24b
commit 22b0fdb3e6
49 changed files with 6574 additions and 6119 deletions

View File

@@ -31,18 +31,32 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
this.pushIndent();
}},
emitTestPrologue:{value:function(name) {
emitTestPrologue:{value:function(name, experiments) {
this.push('[Test]');
this.push('public void Test_' + name + '()');
this.push('{');
this.pushIndent();
if (experiments.length > 0) {
for (var i in experiments) {
this.push('CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.' + experiments[i] +', true);');
}
this.push('');
}
}},
emitTestTreePrologue:{value:function(nodeName) {
this.push('CSSNode ' + nodeName + ' = new CSSNode();');
}},
emitTestEpilogue:{value:function() {
emitTestEpilogue:{value:function(experiments) {
if (experiments.length > 0) {
this.push('');
for (var i in experiments) {
this.push('CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.' + experiments[i] +', false);');
}
}
this.popIndent();
this.push([
'}',
@@ -61,7 +75,7 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
}},
AssertEQ:{value:function(v0, v1) {
this.push('Assert.AreEqual(' + v0 + ', ' + v1 + ');');
this.push('Assert.AreEqual(' + v0 + 'f, ' + v1 + ');');
}},
CSSAlignAuto:{value:'CSSAlign.Auto'},
@@ -141,7 +155,7 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
}},
CSSNodeStyleSetBorder:{value:function(nodeName, edge, value) {
this.push(nodeName + '.SetBorder(' + edge + ', ' + value + ');');
this.push(nodeName + '.SetBorder(' + edge + ', ' + value + 'f);');
}},
CSSNodeStyleSetDirection:{value:function(nodeName, value) {
@@ -149,7 +163,7 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
}},
CSSNodeStyleSetFlexBasis:{value:function(nodeName, value) {
this.push(nodeName + '.FlexBasis = ' + value + ';');
this.push(nodeName + '.FlexBasis = ' + value + 'f;');
}},
CSSNodeStyleSetFlexDirection:{value:function(nodeName, value) {
@@ -157,11 +171,11 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
}},
CSSNodeStyleSetFlexGrow:{value:function(nodeName, value) {
this.push(nodeName + '.FlexGrow = ' + value + ';');
this.push(nodeName + '.FlexGrow = ' + value + 'f;');
}},
CSSNodeStyleSetFlexShrink:{value:function(nodeName, value) {
this.push(nodeName + '.FlexShrink = ' + value + ';');
this.push(nodeName + '.FlexShrink = ' + value + 'f;');
}},
CSSNodeStyleSetFlexWrap:{value:function(nodeName, value) {
@@ -169,7 +183,7 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
}},
CSSNodeStyleSetHeight:{value:function(nodeName, value) {
this.push(nodeName + '.StyleHeight = ' + value + ';');
this.push(nodeName + '.StyleHeight = ' + value + 'f;');
}},
CSSNodeStyleSetJustifyContent:{value:function(nodeName, value) {
@@ -177,23 +191,23 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
}},
CSSNodeStyleSetMargin:{value:function(nodeName, edge, value) {
this.push(nodeName + '.SetMargin(' + edge + ', ' + value + ');');
this.push(nodeName + '.SetMargin(' + edge + ', ' + value + 'f);');
}},
CSSNodeStyleSetMaxHeight:{value:function(nodeName, value) {
this.push(nodeName + '.StyleMaxHeight = ' + value + ';');
this.push(nodeName + '.StyleMaxHeight = ' + value + 'f;');
}},
CSSNodeStyleSetMaxWidth:{value:function(nodeName, value) {
this.push(nodeName + '.StyleMaxWidth = ' + value + ';');
this.push(nodeName + '.StyleMaxWidth = ' + value + 'f;');
}},
CSSNodeStyleSetMinHeight:{value:function(nodeName, value) {
this.push(nodeName + '.StyleMinHeight = ' + value + ';');
this.push(nodeName + '.StyleMinHeight = ' + value + 'f;');
}},
CSSNodeStyleSetMinWidth:{value:function(nodeName, value) {
this.push(nodeName + '.StyleMinWidth = ' + value + ';');
this.push(nodeName + '.StyleMinWidth = ' + value + 'f;');
}},
CSSNodeStyleSetOverflow:{value:function(nodeName, value) {
@@ -201,11 +215,11 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
}},
CSSNodeStyleSetPadding:{value:function(nodeName, edge, value) {
this.push(nodeName + '.SetPadding(' + edge + ', ' + value + ');');
this.push(nodeName + '.SetPadding(' + edge + ', ' + value + 'f);');
}},
CSSNodeStyleSetPosition:{value:function(nodeName, edge, value) {
this.push(nodeName + '.SetPosition(' + edge + ', ' + value + ');');
this.push(nodeName + '.SetPosition(' + edge + ', ' + value + 'f);');
}},
CSSNodeStyleSetPositionType:{value:function(nodeName, value) {
@@ -213,6 +227,6 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
}},
CSSNodeStyleSetWidth:{value:function(nodeName, value) {
this.push(nodeName + '.StyleWidth = ' + value + ';');
this.push(nodeName + '.StyleWidth = ' + value + 'f;');
}},
});