-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add exemplar fixtures * Enable exemplar analyzers * Remove fruit-picker from list
- Loading branch information
1 parent
50a48bf
commit 304f89a
Showing
108 changed files
with
6,211 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@exercism/javascript-analyzer", | ||
"version": "0.15.0", | ||
"version": "0.16.0", | ||
"description": "Exercism analyzer for javascript", | ||
"repository": "https://github.com/exercism/javascript-analyzer", | ||
"author": "Derk-Jan Karrenbeld <[email protected]>", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { DirectoryWithConfigInput } from '@exercism/static-analysis' | ||
import path from 'path' | ||
import { ExemplarAnalyzer } from '~src/analyzers/concept/__exemplar' | ||
import { EXEMPLAR_SOLUTION } from '~src/comments/shared' | ||
import { makeAnalyze, makeOptions } from '~test/helpers/smoke' | ||
;[ | ||
'amusement-park', | ||
'bird-watcher', | ||
'coordinate-transformation', | ||
'elyses-analytic-enchantments', | ||
'elyses-destructured-enchantments', | ||
'elyses-enchantments', | ||
'elyses-looping-enchantments', | ||
'elyses-transformative-enchantments', | ||
'factory-sensors', | ||
// 'fruit-picker', | ||
'high-score-board', | ||
'lasagna-master', | ||
'lucky-numbers', | ||
'mixed-juices', | ||
'nullability', | ||
'ozans-playlist', | ||
'pizza-order', | ||
'translation-service', | ||
'vehicle-purchase', | ||
].forEach((exercise) => { | ||
const inputDir = path.join( | ||
__dirname, | ||
'..', | ||
'..', | ||
'fixtures', | ||
exercise, | ||
'exemplar' | ||
) | ||
|
||
const analyze = makeAnalyze( | ||
() => new ExemplarAnalyzer(), | ||
makeOptions({ | ||
get inputDir(): string { | ||
return inputDir | ||
}, | ||
get exercise(): string { | ||
return exercise | ||
}, | ||
}) | ||
) | ||
|
||
describe(`When running analysis on ${exercise}`, () => { | ||
it('recognises the exemplar solution', async () => { | ||
const input = new DirectoryWithConfigInput(inputDir) | ||
|
||
const [solution] = await input.read() | ||
const output = await analyze(solution) | ||
|
||
expect(output.comments.length).toBe(1) | ||
expect(output.comments[0].type).toBe('celebratory') | ||
expect(output.comments[0].externalTemplate).toBe( | ||
EXEMPLAR_SOLUTION().externalTemplate | ||
) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"blurb": "Learn about undefined and null by managing visitors and tickets at an amusement park.", | ||
"authors": ["junedev"], | ||
"contributors": [], | ||
"files": { | ||
"solution": ["amusement-park.js"], | ||
"test": ["amusement-park.spec.js"], | ||
"exemplar": [".meta/exemplar.js"] | ||
}, | ||
"forked_from": ["ruby/amusement-park"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/// <reference path="../global.d.ts" /> | ||
// @ts-check | ||
|
||
/** | ||
* Creates a new visitor. | ||
* | ||
* @param {string} name | ||
* @param {number} age | ||
* @param {string} ticketId | ||
* @returns {Visitor} the visitor that was created | ||
*/ | ||
export function createVisitor(name, age, ticketId) { | ||
return { name, age, ticketId }; | ||
} | ||
|
||
/** | ||
* Revokes a ticket for a visitor. | ||
* | ||
* @param {Visitor} visitor the visitor with an active ticket | ||
* @returns {Visitor} the visitor without a ticket | ||
*/ | ||
export function revokeTicket(visitor) { | ||
visitor.ticketId = null; | ||
return visitor; | ||
} | ||
|
||
/** | ||
* Determines the status a ticket has in the ticket tracking object. | ||
* | ||
* @param {Record<string, string|null>} tickets | ||
* @param {string} ticketId | ||
* @returns {string} ticket status | ||
*/ | ||
export function ticketStatus(tickets, ticketId) { | ||
if (tickets[ticketId] === undefined) { | ||
return 'unknown ticket id'; | ||
} | ||
|
||
if (tickets[ticketId] === null) { | ||
return 'not sold'; | ||
} | ||
|
||
return 'sold to ' + tickets[ticketId]; | ||
} | ||
|
||
/** | ||
* Determines the status a ticket has in the ticket tracking object | ||
* and returns a simplified status message. | ||
* | ||
* @param {Record<string, string|null>} tickets | ||
* @param {string} ticketId | ||
* @returns {string} ticket status | ||
*/ | ||
export function simpleTicketStatus(tickets, ticketId) { | ||
return tickets[ticketId] ?? 'invalid ticket !!!'; | ||
} | ||
|
||
/** | ||
* Determines the version of the GTC that was signed by the visitor. | ||
* | ||
* @param {VisitorWithGtc} visitor | ||
* @returns {string | undefined} version | ||
*/ | ||
export function gtcVersion(visitor) { | ||
return visitor.gtc?.version; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/// <reference path="./global.d.ts" /> | ||
// @ts-check | ||
|
||
/** | ||
* Creates a new visitor. | ||
* | ||
* @param {string} name | ||
* @param {number} age | ||
* @param {string} ticketId | ||
* @returns {Visitor} the visitor that was created | ||
*/ | ||
export function createVisitor(name, age, ticketId) { | ||
return { name, age, ticketId }; | ||
} | ||
|
||
/** | ||
* Revokes a ticket for a visitor. | ||
* | ||
* @param {Visitor} visitor the visitor with an active ticket | ||
* @returns {Visitor} the visitor without a ticket | ||
*/ | ||
export function revokeTicket(visitor) { | ||
visitor.ticketId = null; | ||
return visitor; | ||
} | ||
|
||
/** | ||
* Determines the status a ticket has in the ticket tracking object. | ||
* | ||
* @param {Record<string, string|null>} tickets | ||
* @param {string} ticketId | ||
* @returns {string} ticket status | ||
*/ | ||
export function ticketStatus(tickets, ticketId) { | ||
if (tickets[ticketId] === undefined) { | ||
return 'unknown ticket id'; | ||
} | ||
|
||
if (tickets[ticketId] === null) { | ||
return 'not sold'; | ||
} | ||
|
||
return 'sold to ' + tickets[ticketId]; | ||
} | ||
|
||
/** | ||
* Determines the status a ticket has in the ticket tracking object | ||
* and returns a simplified status message. | ||
* | ||
* @param {Record<string, string|null>} tickets | ||
* @param {string} ticketId | ||
* @returns {string} ticket status | ||
*/ | ||
export function simpleTicketStatus(tickets, ticketId) { | ||
return tickets[ticketId] ?? 'invalid ticket !!!'; | ||
} | ||
|
||
/** | ||
* Determines the version of the GTC that was signed by the visitor. | ||
* | ||
* @param {VisitorWithGtc} visitor | ||
* @returns {string | undefined} version | ||
*/ | ||
export function gtcVersion(visitor) { | ||
return visitor.gtc?.version; | ||
} |
Oops, something went wrong.