Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert arrow, arrow unicode, colors, constants, language
- Loading branch information
1 parent
a2b70f9
commit dd8b528
Showing
8 changed files
with
385 additions
and
4 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
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,86 @@ | ||
/* eslint-disable max-len */ | ||
|
||
const jssm = require('../../../build/jssm.es5.cjs.js'); | ||
|
||
|
||
|
||
|
||
|
||
describe('arrow_direction', () => { | ||
|
||
test('verify ←', () => expect(jssm.arrow_direction('←')).toBe('left')); | ||
test('verify ⇐', () => expect(jssm.arrow_direction('⇐')).toBe('left')); | ||
test('verify ↚', () => expect(jssm.arrow_direction('↚')).toBe('left')); | ||
|
||
test('verify →', () => expect(jssm.arrow_direction('→')).toBe('right')); | ||
test('verify ⇒', () => expect(jssm.arrow_direction('⇒')).toBe('right')); | ||
test('verify ↛', () => expect(jssm.arrow_direction('↛')).toBe('right')); | ||
|
||
test('verify ↔', () => expect(jssm.arrow_direction('↔')).toBe('both')); | ||
test('verify ⇔', () => expect(jssm.arrow_direction('⇔')).toBe('both')); | ||
test('verify ↮', () => expect(jssm.arrow_direction('↮')).toBe('both')); | ||
|
||
test('verify ←⇒', () => expect(jssm.arrow_direction('←⇒')).toBe('both')); | ||
test('verify ⇐→', () => expect(jssm.arrow_direction('⇐→')).toBe('both')); | ||
test('verify ←↛', () => expect(jssm.arrow_direction('←↛')).toBe('both')); | ||
test('verify ↚→', () => expect(jssm.arrow_direction('↚→')).toBe('both')); | ||
test('verify ⇐↛', () => expect(jssm.arrow_direction('⇐↛')).toBe('both')); | ||
test('verify ↚⇒', () => expect(jssm.arrow_direction('↚⇒')).toBe('both')); | ||
|
||
}); | ||
|
||
|
||
|
||
|
||
|
||
describe('arrow_left_kind', () => { | ||
|
||
test('verify →', () => expect(jssm.arrow_left_kind('→')).toBe('none')); | ||
test('verify ⇒', () => expect(jssm.arrow_left_kind('⇒')).toBe('none')); | ||
test('verify ↛', () => expect(jssm.arrow_left_kind('↛')).toBe('none')); | ||
|
||
test('verify ←', () => expect(jssm.arrow_left_kind('←')).toBe('legal')); | ||
test('verify ↔', () => expect(jssm.arrow_left_kind('↔')).toBe('legal')); | ||
test('verify ←⇒', () => expect(jssm.arrow_left_kind('←⇒')).toBe('legal')); | ||
test('verify ←↛', () => expect(jssm.arrow_left_kind('←↛')).toBe('legal')); | ||
|
||
test('verify ⇐', () => expect(jssm.arrow_left_kind('⇐')).toBe('main')); | ||
test('verify ⇔', () => expect(jssm.arrow_left_kind('⇔')).toBe('main')); | ||
test('verify ⇐→', () => expect(jssm.arrow_left_kind('⇐→')).toBe('main')); | ||
test('verify ⇐↛', () => expect(jssm.arrow_left_kind('⇐↛')).toBe('main')); | ||
|
||
test('verify ↚', () => expect(jssm.arrow_left_kind('↚')).toBe('forced')); | ||
test('verify ↮', () => expect(jssm.arrow_left_kind('↮')).toBe('forced')); | ||
test('verify ↚→', () => expect(jssm.arrow_left_kind('↚→')).toBe('forced')); | ||
test('verify ↚⇒', () => expect(jssm.arrow_left_kind('↚⇒')).toBe('forced')); | ||
|
||
}); | ||
|
||
|
||
|
||
|
||
|
||
describe('arrow_right_kind', () => { | ||
|
||
test('verify ←', () => expect(jssm.arrow_right_kind('←')).toBe('none')); | ||
test('verify ⇐', () => expect(jssm.arrow_right_kind('⇐')).toBe('none')); | ||
test('verify ↚', () => expect(jssm.arrow_right_kind('↚')).toBe('none')); | ||
|
||
test('verify →', () => expect(jssm.arrow_right_kind('→')).toBe('legal')); | ||
test('verify ↔', () => expect(jssm.arrow_right_kind('↔')).toBe('legal')); | ||
test('verify ⇐→', () => expect(jssm.arrow_right_kind('⇐→')).toBe('legal')); | ||
test('verify ↚→', () => expect(jssm.arrow_right_kind('↚→')).toBe('legal')); | ||
|
||
test('verify ⇒', () => expect(jssm.arrow_right_kind('⇒')).toBe('main')); | ||
test('verify ⇔', () => expect(jssm.arrow_right_kind('⇔')).toBe('main')); | ||
test('verify ←⇒', () => expect(jssm.arrow_right_kind('←⇒')).toBe('main')); | ||
test('verify ↚⇒', () => expect(jssm.arrow_right_kind('↚⇒')).toBe('main')); | ||
|
||
test('verify ↛', () => expect(jssm.arrow_right_kind('↛')).toBe('forced')); | ||
test('verify ↮', () => expect(jssm.arrow_right_kind('↮')).toBe('forced')); | ||
test('verify ←↛', () => expect(jssm.arrow_right_kind('←↛')).toBe('forced')); | ||
test('verify ⇐↛', () => expect(jssm.arrow_right_kind('⇐↛')).toBe('forced')); | ||
|
||
}); | ||
|
||
// stochable |
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,122 @@ | ||
|
||
/* eslint-disable max-len */ | ||
|
||
const jssm = require('../jssm'); | ||
|
||
|
||
|
||
|
||
|
||
describe('arrow_direction', () => { | ||
|
||
const lefts = ['<-', '<=', '<~', '←', '⇐', '↚'], | ||
rights = ['->', '=>', '~>', '→', '⇒', '↛'], | ||
boths = ['<->', '<=>', '<~>', | ||
'<-=>', '<-~>', '<=->', '<=~>', '<~->', '<~=>', | ||
'←⇒', '←↛', '⇐→', '⇐↛', '↚→', '↚⇒', | ||
'←=>', '←~>', '⇐->', '⇐~>', '↚->', '↚=>', | ||
'<-⇒', '<-↛', '<=→', '<=↛', '<~→', '<~⇒' ], | ||
|
||
check = (lab, dir) => | ||
it(lab, () => | ||
expect( jssm.arrow_direction(lab) ).toBe(dir) ); | ||
|
||
lefts.map( e => check(e, 'left') ); | ||
rights.map( e => check(e, 'right') ); | ||
boths.map( e => check(e, 'both') ); | ||
|
||
/* | ||
test('<-', () => expect(jssm.arrow_direction('<-') ).toBe('left') ); | ||
test('<=', () => expect(jssm.arrow_direction('<=') ).toBe('left') ); | ||
test('<~', () => expect(jssm.arrow_direction('<~') ).toBe('left') ); | ||
test('->', () => expect(jssm.arrow_direction('->') ).toBe('right') ); | ||
test('=>', () => expect(jssm.arrow_direction('=>') ).toBe('right') ); | ||
test('~>', () => expect(jssm.arrow_direction('~>') ).toBe('right') ); | ||
test('<->', () => expect(jssm.arrow_direction('<->') ).toBe('both') ); | ||
test('<=>', () => expect(jssm.arrow_direction('<=>') ).toBe('both') ); | ||
test('<~>', () => expect(jssm.arrow_direction('<~>') ).toBe('both') ); | ||
test('<-=>', () => expect(jssm.arrow_direction('<-=>') ).toBe('both') ); | ||
test('<=->', () => expect(jssm.arrow_direction('<=->') ).toBe('both') ); | ||
test('<-~>', () => expect(jssm.arrow_direction('<-~>') ).toBe('both') ); | ||
test('<~->', () => expect(jssm.arrow_direction('<~->') ).toBe('both') ); | ||
test('<=~>', () => expect(jssm.arrow_direction('<=~>') ).toBe('both') ); | ||
test('<~=>', () => expect(jssm.arrow_direction('<~=>') ).toBe('both') ); | ||
*/ | ||
|
||
}); | ||
|
||
|
||
|
||
|
||
|
||
describe('arrow_left_kind', () => { | ||
|
||
test('->', () => expect(jssm.arrow_left_kind('->') ).toBe('none') ); | ||
test('=>', () => expect(jssm.arrow_left_kind('=>') ).toBe('none') ); | ||
test('~>', () => expect(jssm.arrow_left_kind('~>') ).toBe('none') ); | ||
|
||
test('<-', () => expect(jssm.arrow_left_kind('<-') ).toBe('legal') ); | ||
test('<->', () => expect(jssm.arrow_left_kind('<->') ).toBe('legal') ); | ||
test('<-=>', () => expect(jssm.arrow_left_kind('<-=>') ).toBe('legal') ); | ||
test('<-~>', () => expect(jssm.arrow_left_kind('<-~>') ).toBe('legal') ); | ||
|
||
test('<=', () => expect(jssm.arrow_left_kind('<=') ).toBe('main') ); | ||
test('<=>', () => expect(jssm.arrow_left_kind('<=>') ).toBe('main') ); | ||
test('<=->', () => expect(jssm.arrow_left_kind('<=->') ).toBe('main') ); | ||
test('<=~>', () => expect(jssm.arrow_left_kind('<=~>') ).toBe('main') ); | ||
|
||
test('<~', () => expect(jssm.arrow_left_kind('<~') ).toBe('forced') ); | ||
test('<~>', () => expect(jssm.arrow_left_kind('<~>') ).toBe('forced') ); | ||
test('<~->', () => expect(jssm.arrow_left_kind('<~->') ).toBe('forced') ); | ||
test('<~=>', () => expect(jssm.arrow_left_kind('<~=>') ).toBe('forced') ); | ||
|
||
}); | ||
|
||
|
||
|
||
|
||
|
||
describe('arrow_right_kind', () => { | ||
|
||
test('<-', () => expect(jssm.arrow_right_kind('<-') ).toBe('none') ); | ||
test('<=', () => expect(jssm.arrow_right_kind('<=') ).toBe('none') ); | ||
test('<~', () => expect(jssm.arrow_right_kind('<~') ).toBe('none') ); | ||
|
||
test('->', () => expect(jssm.arrow_right_kind('->') ).toBe('legal') ); | ||
test('<->', () => expect(jssm.arrow_right_kind('<->') ).toBe('legal') ); | ||
test('<=->', () => expect(jssm.arrow_right_kind('<=->') ).toBe('legal') ); | ||
test('<~->', () => expect(jssm.arrow_right_kind('<~->') ).toBe('legal') ); | ||
|
||
test('=>', () => expect(jssm.arrow_right_kind('=>') ).toBe('main') ); | ||
test('<=>', () => expect(jssm.arrow_right_kind('<=>') ).toBe('main') ); | ||
test('<-=>', () => expect(jssm.arrow_right_kind('<-=>') ).toBe('main') ); | ||
test('<~=>', () => expect(jssm.arrow_right_kind('<~=>') ).toBe('main') ); | ||
|
||
test('~>', () => expect(jssm.arrow_right_kind('~>') ).toBe('forced') ); | ||
test('<~>', () => expect(jssm.arrow_right_kind('<~>') ).toBe('forced') ); | ||
test('<-~>', () => expect(jssm.arrow_right_kind('<-~>') ).toBe('forced') ); | ||
test('<=~>', () => expect(jssm.arrow_right_kind('<=~>') ).toBe('forced') ); | ||
|
||
}); | ||
|
||
|
||
|
||
|
||
|
||
describe('arrow error catchery', () => { | ||
|
||
test('unknown arrow direction throws', () => | ||
expect( () => jssm.arrow_direction('boop') ).toThrow() ); | ||
|
||
test('unknown arrow left kind throws', () => | ||
expect( () => jssm.arrow_left_kind('boop') ).toThrow() ); | ||
|
||
test('unknown arrow right kind throws', () => | ||
expect( () => jssm.arrow_right_kind('boop') ).toThrow() ); | ||
|
||
}); | ||
|
||
// stochable |
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,64 @@ | ||
|
||
import { NamedColors } from './constants.spec'; | ||
|
||
|
||
|
||
|
||
|
||
const jssm = require('../jssm'), | ||
sm = jssm.sm; | ||
|
||
|
||
|
||
|
||
|
||
describe('Colors', () => { | ||
|
||
/* eslint-disable max-nested-callbacks */ | ||
|
||
const ColorSets = [ | ||
{ label: "Named colors", dataset: NamedColors }, | ||
{ label: "Direct colors", dataset: [ '#ABC', '#ABCF', '#AABBCC', '#AABBCCFF' ] } | ||
]; | ||
|
||
ColorSets.map( ({label, dataset}) => | ||
|
||
dataset.map(col => { | ||
|
||
// edge things | ||
['edge_color'].map(prop => | ||
[col, col.toLowerCase()].map(repres => | ||
test(`${label} - Color "${repres}" parses as ${prop}`, () => | ||
|
||
expect( () => { | ||
const _foo = sm`machine_name: bob; a-> { ${prop}: ${repres}; } b;`; | ||
}).not.toThrow() | ||
|
||
) | ||
) | ||
); | ||
|
||
// state things | ||
['color', 'background-color', 'text-color', 'border-color'].map(prop => | ||
[col, col.toLowerCase()].map(repres => | ||
test(`${label} - Color "${repres}" parses as ${prop}`, () => | ||
|
||
expect( () => { | ||
const _foo = sm`machine_name: bob; state a: { ${prop}: ${repres}; }; a -> b;`; | ||
}).not.toThrow() | ||
|
||
) | ||
) | ||
); | ||
|
||
}) | ||
); | ||
|
||
/* eslint-enable max-nested-callbacks */ | ||
|
||
}); | ||
|
||
// TODO FIXME COMEBACK tests for the other color types | ||
// TODO FIXME COMEBACK check that the named colors are coming out sensibly | ||
|
||
// TODO FIXME COMEBACK STOCHABLE assert that #f00, #ff0000, #f00f, #ff0000ff, and red all parse as the same color |
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,72 @@ | ||
|
||
/* constant lists for tests */ | ||
|
||
|
||
|
||
|
||
|
||
const Shapes = ["box", "polygon", "ellipse", "oval", "circle", "point", "egg", "triangle", "plaintext", "plain", | ||
"diamond", "trapezium", "parallelogram", "house", "pentagon", "hexagon", "septagon", "octagon", "doublecircle", | ||
"doubleoctagon", "tripleoctagon", "invtriangle", "invtrapezium", "invhouse", "Mdiamond", "Msquare", "Mcircle", "rect", | ||
"rectangle", "square", "star", "none", "underline", "cylinder", "note", "tab", "folder", "box3d", "component", | ||
"promoter", "cds", "terminator", "utr", "primersite", "restrictionsite", "fivepoverhang", "threepoverhang", | ||
"noverhang", "assembly", "signature", "insulator", "ribosite", "rnastab", "proteasesite", "proteinstab", "rpromoter", | ||
"rarrow", "larrow", "lpromoter", "record"]; | ||
|
||
|
||
|
||
|
||
|
||
const NamedColors = ["AliceBlue", "AntiqueWhite", "Aqua", "Aquamarine", "Azure", "Beige", "Bisque", "Black", | ||
"BlanchedAlmond", "Blue", "BlueViolet", "Brown", "BurlyWood", "CadetBlue", "Chartreuse", "Chocolate", "Coral", | ||
"CornflowerBlue", "Cornsilk", "Crimson", "Cyan", "DarkBlue", "DarkCyan", "DarkGoldenRod", "DarkGray", "DarkGrey", | ||
"DarkGreen", "DarkKhaki", "DarkMagenta", "DarkOliveGreen", "Darkorange", "DarkOrchid", "DarkRed", "DarkSalmon", | ||
"DarkSeaGreen", "DarkSlateBlue", "DarkSlateGray", "DarkSlateGrey", "DarkTurquoise", "DarkViolet", "DeepPink", | ||
"DeepSkyBlue", "DimGray", "DimGrey", "DodgerBlue", "FireBrick", "FloralWhite", "ForestGreen", "Fuchsia", "Gainsboro", | ||
"GhostWhite", "Gold", "GoldenRod", "Gray", "Grey", "Green", "GreenYellow", "HoneyDew", "HotPink", "IndianRed", | ||
"Indigo", "Ivory", "Khaki", "Lavender", "LavenderBlush", "LawnGreen", "LemonChiffon", "LightBlue", "LightCoral", | ||
"LightCyan", "LightGoldenRodYellow", "LightGray", "LightGrey", "LightGreen", "LightPink", "LightSalmon", | ||
"LightSeaGreen", "LightSkyBlue", "LightSlateGray", "LightSlateGrey", "LightSteelBlue", "LightYellow", "Lime", | ||
"LimeGreen", "Linen", "Magenta", "Maroon", "MediumAquaMarine", "MediumBlue", "MediumOrchid", "MediumPurple", | ||
"MediumSeaGreen", "MediumSlateBlue", "MediumSpringGreen", "MediumTurquoise", "MediumVioletRed", "MidnightBlue", | ||
"MintCream", "MistyRose", "Moccasin", "NavajoWhite", "Navy", "OldLace", "Olive", "OliveDrab", "Orange", "OrangeRed", | ||
"Orchid", "PaleGoldenRod", "PaleGreen", "PaleTurquoise", "PaleVioletRed", "PapayaWhip", "PeachPuff", "Peru", "Pink", | ||
"Plum", "PowderBlue", "Purple", "Red", "RosyBrown", "RoyalBlue", "SaddleBrown", "Salmon", "SandyBrown", "SeaGreen", | ||
"SeaShell", "Sienna", "Silver", "SkyBlue", "SlateBlue", "SlateGray", "SlateGrey", "Snow", "SpringGreen", "SteelBlue", | ||
"Tan", "Teal", "Thistle", "Tomato", "Turquoise", "Violet", "Wheat", "White", "WhiteSmoke", "Yellow", "YellowGreen"]; | ||
|
||
|
||
|
||
|
||
|
||
const Themes = ["default", "ocean", "none", "modern"]; | ||
|
||
const FlowDirections = ['up','down','left','right']; | ||
|
||
|
||
|
||
|
||
|
||
// for coverage, and because ava throws on no-test files in its test directory | ||
|
||
describe('Constants', () => { | ||
|
||
test('Test shapes list isn\'t empty', () => | ||
expect( Shapes.length > 1 ).toBe(true) ); | ||
|
||
test('Test named colors list isn\'t empty', () => | ||
expect( NamedColors.length > 1 ).toBe(true) ); | ||
|
||
test('Test themes list isn\'t empty', () => | ||
expect( Themes.length > 1 ).toBe(true) ); | ||
|
||
test('Test flow directions list isn\'t empty', () => | ||
expect( FlowDirections.length > 1 ).toBe(true) ); | ||
|
||
}); | ||
|
||
|
||
|
||
|
||
|
||
export { NamedColors, Shapes, Themes, FlowDirections }; |
Oops, something went wrong.