本文整理匯總了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));
}