Пример #1
0
 /**
  * Asserts that each top-level variable has associative (or not) {@link DartBinaryExpression}
  * value.
  */
 private void assert_isAssociative(boolean expected) throws DartModelException {
   DartUnit unit = DartCompilerUtilities.resolveUnit(testUnit);
   for (DartNode topLevelNode : unit.getTopLevelNodes()) {
     if (topLevelNode instanceof DartFieldDefinition) {
       DartFieldDefinition fieldDefinition = (DartFieldDefinition) topLevelNode;
       List<DartField> fields = fieldDefinition.getFields();
       if (fields.size() == 1) {
         DartBinaryExpression expression = (DartBinaryExpression) fields.get(0).getValue();
         assertEquals(expected, ExtractUtils.isAssociative(expression));
       }
     }
   }
 }
Пример #2
0
 /** @return the {@link DartExpression} of top-level variable "x" in the given source. */
 private DartExpression getMarkerVariableExpression(String... lines) throws Exception {
   setTestUnitContent(lines);
   DartUnit unit = DartCompilerUtilities.resolveUnit(testUnit);
   for (DartNode topLevelNode : unit.getTopLevelNodes()) {
     if (topLevelNode instanceof DartFieldDefinition) {
       DartFieldDefinition fieldDefinition = (DartFieldDefinition) topLevelNode;
       List<DartField> fields = fieldDefinition.getFields();
       if (fields.size() == 1 && fields.get(0).getName().getName().equals("x")) {
         return fields.get(0).getValue();
       }
     }
   }
   fail("Field 'x' not found");
   return null;
 }