本文整理汇总了Java中com.google.javascript.jscomp.jsonml.TagAttr类的典型用法代码示例。如果您正苦于以下问题:Java TagAttr类的具体用法?Java TagAttr怎么用?Java TagAttr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TagAttr类属于com.google.javascript.jscomp.jsonml包,在下文中一共展示了TagAttr类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAssignExpr
import com.google.javascript.jscomp.jsonml.TagAttr; //导入依赖的package包/类
public void testAssignExpr() throws Exception {
// correct statement
testValidation("" +
"['AssignExpr',{'op':'='}," +
"['IdExpr',{'name':'x'}]," +
"['LiteralExpr',{'type':'number','value':1}]]");
// wrong number of children
testNotEnoughChildrenValidation("" +
"['AssignExpr',{'op':'='}," +
"['IdExpr',{'name':'x'}]]",
TagType.AssignExpr, 2, 1);
testTooManyChildrenValidation("" +
"['AssignExpr',{'op':'='}," +
"['IdExpr',{'name':'x'}]," +
"['IdExpr',{'name':'y'}]," +
"['IdExpr',{'name':'z'}]]",
TagType.AssignExpr, 2, 3);
// missing attribute
testMissingArgument("" +
"['AssignExpr',{}," +
"['IdExpr',{'name':'x'}]," +
"['LiteralExpr',{'type':'number','value':1}]]",
TagAttr.OP, TagType.AssignExpr);
}
示例2: testBinaryExpr
import com.google.javascript.jscomp.jsonml.TagAttr; //导入依赖的package包/类
public void testBinaryExpr() throws Exception {
// correct statement
testValidation("" +
"['BinaryExpr',{'op':'+'}," +
"['IdExpr',{'name':'a'}]," +
"['LiteralExpr',{'type':'number','value':1}]]");
// wrong number of children
testNotEnoughChildrenValidation("" +
"['BinaryExpr',{'op':'+'}," +
"['IdExpr',{'name':'a'}]]",
TagType.BinaryExpr, 2, 1);
testTooManyChildrenValidation("" +
"['BinaryExpr',{'op':'&&'}," +
"['IdExpr',{'name':'a'}]," +
"['IdExpr',{'name':'b'}]," +
"['IdExpr',{'name':'c'}]]",
TagType.BinaryExpr, 2, 3);
// missing attribute
testMissingArgument("" +
"['BinaryExpr',{}," +
"['IdExpr',{'name':'a'}]," +
"['LiteralExpr',{'type':'number','value':1}]]",
TagAttr.OP, TagType.BinaryExpr);
}
示例3: testCountExprValidation
import com.google.javascript.jscomp.jsonml.TagAttr; //导入依赖的package包/类
public void testCountExprValidation() throws Exception {
// correct statement
testValidation("" +
"['CountExpr',{'isPrefix':false,'op':'++'}," +
"['IdExpr',{'name':'x'}]]");
// wrong number of children
testTooManyChildrenValidation("" +
"['CountExpr',{'isPrefix':false,'op':'++'}," +
"['IdExpr',{'name':'x'}]," +
"['IdExpr',{'name':'y'}]]",
TagType.CountExpr, 1, 2);
// missing attribute
testMissingArgument("" +
"['CountExpr',{'op':'++'}," +
"['IdExpr',{'name':'x'}]]",
TagAttr.IS_PREFIX, TagType.CountExpr);
testMissingArgument("" +
"['CountExpr',{'isPrefix':false}," +
"['IdExpr',{'name':'x'}]]",
TagAttr.OP, TagType.CountExpr);
}
示例4: testInvokeExprValidation
import com.google.javascript.jscomp.jsonml.TagAttr; //导入依赖的package包/类
public void testInvokeExprValidation() throws Exception {
// correct statement
testValidation("" +
"['InvokeExpr',{'op':'.'}," +
"['IdExpr',{'name':'x'}]," +
"['LiteralExpr',{'type':'string','value':'foo'}]]");
// wrong number of children
testNotEnoughChildrenValidation("" +
"['InvokeExpr',{'op':'[]'}," +
"['IdExpr',{'name':'x'}]]",
TagType.InvokeExpr, 2, 1);
// missing attribute
testMissingArgument("" +
"['InvokeExpr',{}," +
"['IdExpr',{'name':'x'}]," +
"['LiteralExpr',{'type':'string','value':'foo'}]]",
TagAttr.OP, TagType.InvokeExpr);
}
示例5: testLabelledStmtValidation
import com.google.javascript.jscomp.jsonml.TagAttr; //导入依赖的package包/类
public void testLabelledStmtValidation() throws Exception {
// correct statement
testValidation("" +
"['LabelledStmt',{'label':'s'}," +
"['IdExpr',{'name':'x'}]]");
// wrong number of children
testNotEnoughChildrenValidation("" +
"['LabelledStmt',{'label':'s'}]",
TagType.LabelledStmt, 1, 0);
testTooManyChildrenValidation("" +
"['LabelledStmt',{'label':'s'}," +
"['IdExpr',{'name':'x'}]," +
"['IdExpr',{'name':'y'}]]",
TagType.LabelledStmt, 1, 2);
// missing attribute
testMissingArgument("" +
"['LabelledStmt',{}," +
"['IdExpr',{'name':'x'}]]",
TagAttr.LABEL, TagType.LabelledStmt);
}
示例6: testLiteralExprValidation
import com.google.javascript.jscomp.jsonml.TagAttr; //导入依赖的package包/类
public void testLiteralExprValidation() throws Exception {
// correct statement
testValidation("" +
"['LiteralExpr',{'type':'string','value':'x'}]");
testValidation("" +
"['LiteralExpr',{'type':'boolean','value':'true'}]");
testValidation("" +
"['LiteralExpr',{'type':'number','value':'1.0'}]");
// wrong number of children
testTooManyChildrenValidation("" +
"['LiteralExpr',{'type':'number','value':'1.0'}," +
"['BlockStmt',{}]]",
TagType.LiteralExpr, 0, 1);
// missing attribute
testMissingArgument("" +
"['LiteralExpr',{'type':'string'}]",
TagAttr.VALUE, TagType.LiteralExpr);
testMissingArgument("" +
"['LiteralExpr',{'value':'1.0'}]",
TagAttr.TYPE, TagType.LiteralExpr);
}
示例7: testRegExpExprValidation
import com.google.javascript.jscomp.jsonml.TagAttr; //导入依赖的package包/类
public void testRegExpExprValidation() throws Exception {
// correct statement
testValidation("" +
"['RegExpExpr',{'body':'abc','flags':''}]");
testValidation("" +
"['RegExpExpr',{'body':'abc','flags':'g'}]");
// wrong number of children
testTooManyChildrenValidation("" +
"['RegExpExpr',{'body':'abc','flags':'g'}," +
"['IdExpr',{'name':'a'}]]",
TagType.RegExpExpr, 0, 1);
// missing attribute
testMissingArgument("" +
"['RegExpExpr',{'body':'abc'}]",
TagAttr.FLAGS, TagType.RegExpExpr);
testMissingArgument("" +
"['RegExpExpr',{'flags':'g'}]",
TagAttr.BODY, TagType.RegExpExpr);
}
示例8: testUnaryExprValidation
import com.google.javascript.jscomp.jsonml.TagAttr; //导入依赖的package包/类
public void testUnaryExprValidation() throws Exception {
// correct statement
testValidation("" +
"['UnaryExpr',{'op':'-'}," +
"['IdExpr',{'name':'x'}]]");
testValidation("" +
"['UnaryExpr',{'op':'!'}," +
"['CallExpr',{}," +
"['IdExpr',{'name':'f'}]," +
"['IdExpr',{'name':'x'}]]]");
// wrong number of children
testNotEnoughChildrenValidation("" +
"['UnaryExpr',{'op':'-'}]",
TagType.UnaryExpr, 1, 0);
testTooManyChildrenValidation("" +
"['UnaryExpr',{'op':'+'}," +
"['IdExpr',{'name':'x'}]," +
"['IdExpr',{'name':'y'}]]",
TagType.UnaryExpr, 1, 2);
// missing attribute
testMissingArgument("" +
"['UnaryExpr',{}," +
"['IdExpr',{'name':'x'}]]",
TagAttr.OP, TagType.UnaryExpr);
}
示例9: testDataProp
import com.google.javascript.jscomp.jsonml.TagAttr; //导入依赖的package包/类
public void testDataProp() throws Exception {
// correct statement
testValidation("" +
"['DataProp',{'name':'x'}," +
"['LiteralExpr',{'type':'number','value':1}]]");
// wrong number of children
testNotEnoughChildrenValidation("" +
"['DataProp',{'name':'x'}]",
TagType.DataProp, 1, 0);
// missing argument
testMissingArgument("" +
"['DataProp', {}," +
"['LiteralExpr',{'type':'number','value':1}]]",
TagAttr.NAME, TagType.DataProp);
}
示例10: testIdExprValidation
import com.google.javascript.jscomp.jsonml.TagAttr; //导入依赖的package包/类
public void testIdExprValidation() throws Exception {
// correct statement
testValidation("" +
"['IdExpr',{'name':'x'}]");
// wrong number of children
testTooManyChildrenValidation("" +
"['IdExpr',{'name':'x'}," +
"['BlockStmt',{}]]",
TagType.IdExpr, 0, 1);
// missing name argument
testMissingArgument("" +
"['IdExpr', {}]",
TagAttr.NAME, TagType.IdExpr);
}
示例11: testIdPattValidation
import com.google.javascript.jscomp.jsonml.TagAttr; //导入依赖的package包/类
public void testIdPattValidation() throws Exception {
// correct statement
testValidation("" +
"['IdPatt',{'name':'x'}]");
// wrong number of children
testTooManyChildrenValidation("" +
"['IdPatt',{'name':'x'}," +
"['BlockStmt',{}]]",
TagType.IdPatt, 0, 1);
// missing name argument
testMissingArgument("" +
"['IdPatt', {}]",
TagAttr.NAME, TagType.IdPatt);
}
示例12: testMissingArgument
import com.google.javascript.jscomp.jsonml.TagAttr; //导入依赖的package包/类
private void testMissingArgument(String jsonml, TagAttr attr, TagType type)
throws Exception {
testValidation(jsonml,
String.format(Validator.MISSING_ARGUMENT, attr, type));
}