Skip to content

Commit

Permalink
Tweak statuses
Browse files Browse the repository at this point in the history
exercism/automated-analysis#53

Merge "approve_as_optimal" and "approve_with_comment" into a single status "approve", and rename the "disapprove_with_comment" status to "disapprove".
  • Loading branch information
SleeplessByte committed Jul 3, 2019
1 parent b32e6dc commit 0aebb03
Show file tree
Hide file tree
Showing 16 changed files with 1,084 additions and 139 deletions.
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ from the track anatomy project deem to be the set of reasonable solutions.

#### Abstract Syntax Approach

These solutions will be your baseline for `approve_as_optimal`, one of the
expected outputs. If your analyzer will be based on Abstract Syntax Tree
parsing, you can run these analyzers through the included ASTParser, or use
[AST explorer][ast-explorer] and make sure it's set to the correct parser (at
moment of writing this is `@typescript/eslint-parser`).
These solutions will be your baseline for `approve`, one of the expected
outputs. If your analyzer will be based on Abstract Syntax Tree parsing, you can
run these analyzers through the included ASTParser, or use [AST explorer][ast-explorer]
and make sure it's set to the correct parser (at moment of writing this is
`@typescript/eslint-parser`).

**Note**: You may write a different style analyzer, that is _not_ using ASTs.

Expand Down
5 changes: 2 additions & 3 deletions docs/comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ Comments are the output analyzers directly give to the respective parties:

- `refer_to_mentor`: at the moment of writing, the consensus is that comments
will be passed to the mentor;
- `approve_with_comment`: the comments will be passed to the student;
- `disapprove_with_comment`: the comments will be passed to the student;
- `approve_as_optimal`: no comments are passed to _anyone_.
- `approve`: the comments, if any, will be passed to the student;
- `disapprove`: the comments will be passed to the student;

## Using the Comment Factory

Expand Down
8 changes: 4 additions & 4 deletions docs/smoke-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ describe('When running analysis on <slug>', () => {

const output = await analyze(solutionContent)

expect(output.status).toBe('approve_as_optimal');
expect(output.status).toBe('approve');
expect(output.comments.length).toBe(0);
})
})
```

Add additional test cases for `approve_with_comment` and
`disapprove_with_comment`, if your analyzer can actually output those. If you
have explicit code that should always return `refer_to_mentor` add it to.
Add additional test cases for `approve` and `disapprove`, if your analyzer can
actually output those. If you have explicit code that should always return
`refer_to_mentor`, add it too.

**Note**: This is not the place to add an exhaustive test of inputs to outputs.
It's merely trying to detect when one of the known cases changes!
5 changes: 2 additions & 3 deletions docs/snapshot-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ const snapshotTestsGenerator = makeTestGenerator(
)

describe('When running analysis on two-fer fixtures', () => {
snapshotTestsGenerator('approve_as_optimal', [
snapshotTestsGenerator('approve', [
// <fixture numbers>
])
snapshotTestsGenerator('approve_with_comment', [])
snapshotTestsGenerator('disapprove_with_comment', [])
snapshotTestsGenerator('disapprove', [])
snapshotTestsGenerator('refer_to_mentor', [])
})

Expand Down
5 changes: 2 additions & 3 deletions src/batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,8 @@ ${JSON.stringify(
| Status | Count | Comments | Unique | Avg | Median | Total |
| --------------------:| -----:| --------:| ------:| ------:|-------:|--------:|
${line('Approve (optimal)', aggregatedGroups['approve_as_optimal'])}
${line('Approve (comment)', aggregatedGroups['approve_with_comment'])}
${line('Disapprove (comment)', aggregatedGroups['disapprove_with_comment'])}
${line('Approve', aggregatedGroups['approve'])}
${line('Disapprove', aggregatedGroups['disapprove'])}
${line('Refer to mentor', aggregatedGroups['refer_to_mentor'])}
${line('Total', totalData)}
`.trim())
Expand Down
2 changes: 1 addition & 1 deletion src/interface.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ interface Comment {
}

interface Output {
status: 'refer_to_mentor' | 'approve_as_optimal' | 'approve_with_comment' | 'disapprove_with_comment';
status: 'refer_to_mentor' | 'approve' | 'disapprove';
comments: Comment[];

/**
Expand Down
21 changes: 10 additions & 11 deletions src/output/AnalyzerOutput.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
enum SolutionStatus {
/** This is the default situation and should be used when there is any uncertainty. */
/** This is the default situation and should be used when there is any
* uncertainty. */
Redirect = 'refer_to_mentor',
/** To be used when a solution matches pre-known optimal solutions */
ApproveAsOptimal = 'approve_as_optimal',
/** To be used when a solution can be approved but with a known improvement. */
ApproveWithComment = 'approve_with_comment',
/** To be used when a solution can be disapproved as suboptimal and a comment is provided. */
DisapproveWithComment = 'disapprove_with_comment'
/** To be used when a solution matches pre-known optimal solutions or when a
* solution can be approved but with a known improvement. */
Approve = 'approve',
/** To be used when a solution can be disapproved as suboptimal and a comment
* is provided. */
Disapprove = 'disapprove'
}

/**
Expand All @@ -30,9 +31,7 @@ export class AnalyzerOutput implements Output {
* Mark the solution as approved
*/
public approve(): void {
this.status = this.comments.length === 0
? SolutionStatus.ApproveAsOptimal
: SolutionStatus.ApproveWithComment
this.status = SolutionStatus.Approve

this.freeze()
}
Expand All @@ -41,7 +40,7 @@ export class AnalyzerOutput implements Output {
* Mark the solution as dissapproved
*/
public disapprove(): void {
this.status = SolutionStatus.DisapproveWithComment
this.status = SolutionStatus.Disapprove

this.freeze()
}
Expand Down
Loading

0 comments on commit 0aebb03

Please sign in to comment.