Skip to content

Tool wanted: Compare stream. #8

@martinheidegger

Description

@martinheidegger

I came to have the opinion that the important code written for the workshoppers is obfuscated by workshopper-exercise and adventure in different ways but both hang on the same issue: They try to take the work of "comparing output of executed code for you". Now I think that it would be cleanest to get a tool that would do nothing else but compare two streams and end with an error or regular message.

I imagine the API for workshoppers like this:

var submissionStream = /* ... */
if (mode === "verify") {
   var solutionStream = /* ... */
   compareStream({actual: __('{compare.actual}'), expected: __('{compare.expected}')
   }, submissionStream, solutionStream, callback)
} else {
  callback(null, submissionStream)
}

And the API for the compare should tool like this:

var options =  {
  actual: String // The title to be shown for the actual section
  expected: String // The title to be shown for the expected section
}

function callback(err, compared) {
  if (err) {
     // true if 
  }
  compared // Markdown table with the differences highlighted as ``**`` bold ``**`` 
}

var stream = compareStream(options, streamA, streamB, callback); 

The output should be

| {compare.actual} | {compare.expected} |
|---|---|
| line1 | line1 |
| *L*ine2 | *l*ine2 |
| line3 | line3 |
| **line4** | __EOF__ |

Note: If one stream has less lines than the other it should write __EOF__ to indicate that the file ended.

This could replace the way we do comparison now. Anyone up for that?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions