mbeckerle commented on a change in pull request #539:
URL: https://github.com/apache/daffodil/pull/539#discussion_r619561200



##########
File path: daffodil-core/src/test/scala/org/apache/daffodil/util/TestUtils.scala
##########
@@ -191,19 +189,33 @@ object TestUtils {
     if (isError) {
       throw new Exception(msgs)
     }
-    var p = saveAndReload(pf.onPath("/").asInstanceOf[DataProcessor])
+    val p = saveAndReload(pf.onPath("/").asInstanceOf[DataProcessor])
     val pIsError = p.isError
     if (pIsError) {
       val msgs = pf.getDiagnostics.map(_.getMessage()).mkString("\n")
       throw new Exception(msgs)
     }
+    p
+  }
+
+  def runSchemaOnRBC(testSchema: Node, data: ReadableByteChannel, areTracing: 
Boolean = false): (DFDL.ParseResult, Node) = {
+    runSchemaOnInputStream(testSchema, Channels.newInputStream(data), 
areTracing)
+  }
+
+  def runSchemaOnInputStream(testSchema: Node, is: InputStream, areTracing: 
Boolean = false): (DFDL.ParseResult, Node) = {
+    val p = compileSchema(testSchema)
+    runDataProcessorOnInputStream(p, is, areTracing)
+  }
+
+  def runDataProcessorOnInputStream(dp: DataProcessor, is: InputStream, 
areTracing: Boolean = false): (DFDL.ParseResult, Node) = {
+    var p = dp
     p = if (areTracing) {
-      p.withDebugger(builtInTracer).withDebugging(true)
-    } else p
+        p.withDebugger(builtInTracer).withDebugging(true)
+      } else p
     p = p.withValidationMode(ValidationMode.Limited)

Review comment:
       indentation off?

##########
File path: 
daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/PState.scala
##########
@@ -288,7 +285,8 @@ final class PState private (
   }
 
   def currentLocation: DataLocation = {
-    val isAtEnd = !dataInputStream.isDefinedForLength(1)
+    // val isAtEnd = !dataInputStream.isDefinedForLength(1)
+    val isAtEnd = dataInputStream.isAtEnd()

Review comment:
       Arguably, isAtEnd should not be captured into this object at this point, 
and frozen. 
   
   Because it could be false, yet a subsequent operation on the 
InputSourceDataInputStream to look and see if there is more data could get back 
End-of-Data, which would change the answer, that yes, in fact, the parse did 
end at end of data.  

##########
File path: 
daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/PState.scala
##########
@@ -288,7 +285,8 @@ final class PState private (
   }
 
   def currentLocation: DataLocation = {
-    val isAtEnd = !dataInputStream.isDefinedForLength(1)
+    // val isAtEnd = !dataInputStream.isDefinedForLength(1)
+    val isAtEnd = dataInputStream.isAtEnd()

Review comment:
       Arguably, isAtEnd should not be captured into this object at this point, 
and frozen. 
   
   Or rather, the ParseResult object feels like it should be immutable, and all 
characteristics of it taken from the InputSourceDataInputStream (which is 
mutable - can be used to parse again in streaming fashion) should be taken and 
saved. 
   
   The ParseResult isAtEnd feels like it should be frozen at the time the 
parse() returns, subsequent operations on the InputSourceDataInputStream might 
change the isAtEnd status. 

##########
File path: 
daffodil-tdml-lib/src/main/scala/org/apache/daffodil/tdml/TDMLRunner.scala
##########
@@ -837,7 +837,9 @@ case class ParserTestCase(ptc: NodeSeq, parentArg: 
DFDLTestSuite)
     roundTrip: RoundTrip,
     implString: Option[String]) = {
 
-    val nBits = optLengthLimitInBits.get
+    val nBits = optLengthLimitInBits.getOrElse{
+      Assert.invariantFailed("TDML tests should always have a length limit.")

Review comment:
       Change to a plain 
   `Assert.usage(optLengthLimitInBits.isDefined)` will make the coverage error 
go away. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to