Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
1 change: 0 additions & 1 deletion src/parser/tagConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export default class TagConverter {
constructor(tagSpec, hedSchemas) {
this.hedSchemas = hedSchemas
this.tagMapping = hedSchemas.getSchema(tagSpec.library).entries.tags

this.tagSpec = tagSpec
this.tagString = tagSpec.tag
this.tagLevels = this.tagString.split('/')
Expand Down
7 changes: 4 additions & 3 deletions src/parser/tokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,10 @@ export class HedStringTokenizer {
}

handleColon(i) {
if (this.state.librarySchema || this.state.currentToken.trim().includes(CHARACTERS.BLANK)) {
this.state.currentToken += CHARACTERS.COLON // If colon has not been seen, it is a library. Ignore other colons.
} else if (/[^A-Za-z]/.test(this.state.currentToken.trim())) {
const trimmed = this.state.currentToken.trim()
if (this.state.librarySchema || trimmed.includes(CHARACTERS.BLANK) || trimmed.includes(CHARACTERS.SLASH)) {
this.state.currentToken += CHARACTERS.COLON // If colon has been seen or is part of a value.
} else if (/[^A-Za-z]/.test(trimmed)) {
this.pushIssue('invalidTagPrefix', i) // Prefix not alphabetic Ex: "1a:xxx"
} else {
const lib = this.state.currentToken.trimStart()
Expand Down
2 changes: 1 addition & 1 deletion src/schema/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
} from './entries'
import { IssueError } from '../issues/issues'

import classRegex from '../data/json/class_regex.json'
import classRegex from '../data/json/classRegex.json'

const lc = (str) => str.toLowerCase()

Expand Down
2 changes: 1 addition & 1 deletion tests/stringParserTests.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { shouldRun, getHedString } from './testUtilities'

const skipMap = new Map()
const runAll = true
const runMap = new Map([['special-tag-group-tests', ['duration-with-group']]])
const runMap = new Map([['valid-value-tags', ['date-time-value-tag']]])

describe('Null schema objects should cause parsing to bail', () => {
it('Should not proceed if no schema and valid string', () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/tagParserTests.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { SchemaValueTag } from '../src/schema/entries'
// Ability to select individual tests to run
const skipMap = new Map()
const runAll = true
const runMap = new Map([['special-tag-group-tests', ['def-expand-tag-not-in-group']]])
const runMap = new Map([['name-space-tests', ['valid-date-time']]])

describe('TagSpec converter tests using JSON tests', () => {
const schemaMap = new Map([['8.3.0', undefined]])
Expand Down Expand Up @@ -53,7 +53,7 @@ describe('TagSpec converter tests using JSON tests', () => {
if (test.takesValue) {
assert.instanceOf(tag._schemaTag, SchemaValueTag, `${header}: tag should be a takes value tag`)
} else {
assert.notInstanceOf(tag._schemaTag, SchemaValueTag, `${header}: tag should be a takes value tag`)
assert.notInstanceOf(tag._schemaTag, SchemaValueTag, `${header}: tag should not be a takes value tag`)
}
}

Expand Down
10 changes: 10 additions & 0 deletions tests/testData/splitterTests.data.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ export const splitterTestData = [
errors: [],
warnings: [],
},
{
testname: 'date-time-value-string',
explanation: '"Creation-date/2009-04-09T12:04:14" is a an empty string',
schemaVersion: '8.3.0',
stringIn: 'Creation-date/2009-04-09T12:04:14',
allGroupTagCount: [0],
allSubgroupCount: 0,
errors: [],
warnings: [],
},
],
},
]
12 changes: 12 additions & 0 deletions tests/testData/stringParserTests.data.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,18 @@ export const parseTestData = [
errors: [],
warnings: [],
},
{
testname: 'date-time-value-tag',
explanation: '"Label" does not have to take a value"',
schemaVersion: '8.3.0',
stringIn: 'Creation-date/2009-04-09T12:04:14',
stringLong: 'Property/Informational-property/Metadata/Creation-date/2009-04-09T12:04:14',
stringShort: 'Creation-date/2009-04-09T12:04:14',
placeholdersAllowed: false,
definitionsAllowed: false,
errors: [],
warnings: [],
},
],
},
{
Expand Down
23 changes: 22 additions & 1 deletion tests/testData/tagParserTests.data.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { generateIssue } from '../../src/issues/issues'
import { ColumnSpliceSpec, GroupSpec, TagSpec } from '../../src/parser/tokenizer'
import { TagSpec } from '../../src/parser/tokenizer'

export const parsedHedTagTests = [
{
Expand Down Expand Up @@ -504,4 +504,25 @@ export const parsedHedTagTests = [
},
],
},
{
name: 'name-space-tests',
description: 'tests with colons in various places',
warning: false,
tests: [
{
testname: 'valid-date-time',
explanation: '"Creation-date/2009-04-09T12:04:14" is valid and no namespace.',
schemaVersion: '8.3.0',
tagPrefix: null,
fullString: 'Creation-date/2009-04-09T12:04:14',
tagSpec: new TagSpec('Creation-date/2009-04-09T12:04:14', 0, 33, ''),
tagLong: 'Property/Informational-property/Metadata/Creation-date/2009-04-09T12:04:14',
tagShort: 'Creation-date/2009-04-09T12:04:14',
formattedTag: 'property/informational-property/metadata/creation-date/2009-04-09t12:04:14',
canonicalTag: 'Property/Informational-property/Metadata/Creation-date/2009-04-09T12:04:14',
takesValue: true,
error: null,
},
],
},
]
8 changes: 8 additions & 0 deletions tests/testData/tokenizerTests.data.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ export const tokenizerTests = [
groupSpec: new GroupSpec(0, 5, []),
errors: [],
},
{
testname: 'tag-with-date-time',
string: 'Creation-date/2009-04-09T12:04:14',
explanation: 'Creation-date/2009-04-09T12:04:14" has a date-time value',
tagSpecs: [new TagSpec('Creation-date/2009-04-09T12:04:14', 0, 33, '')],
groupSpec: new GroupSpec(0, 33, []),
errors: [],
},
{
testname: 'tag-with-multiple-colons',
string: 'xy:wz x:y',
Expand Down
2 changes: 1 addition & 1 deletion tests/tokenizerTests.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { tokenizerTests } from './testData/tokenizerTests.data'
// Ability to select individual tests to run
const skipMap = new Map()
const runAll = true
const runMap = new Map([['valid-placeholders', []]])
const runMap = new Map([['valid-single-tags', ['tag-with-date-time']]])

describe('Tokenizer validation using JSON tests', () => {
beforeAll(async () => {})
Expand Down
Loading