See #839, #844. Add test for unique language namespaces

Removed check in Beautifiers#buildOptionsForBeautifiers
This commit is contained in:
Glavin Wiechert 2016-03-03 20:06:23 -04:00
parent d637317826
commit bd6e735f08
2 changed files with 23 additions and 7 deletions

View File

@ -1,6 +1,8 @@
Beautifiers = require "../src/beautifiers"
beautifiers = new Beautifiers()
Beautifier = require "../src/beautifiers/beautifier"
Languages = require('../src/languages/')
_ = require('lodash')
# Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs.
#
@ -183,3 +185,24 @@ describe "Atom-Beautify", ->
return v
p.then(cb, cb)
return p
describe "Languages", ->
languages = null
beforeEach ->
languages = new Languages()
describe "Languages::namespace", ->
it "should verify that multiple languages do not share the same namespace", ->
namespaceGroups = _.groupBy(languages.languages, "namespace")
namespacePairs = _.toPairs(namespaceGroups)
namespaceOverlap = _.filter(namespacePairs, ([namespace, group]) -> group.length > 1)
console.log('namespaces', namespaceGroups, namespacePairs, namespaceOverlap)
expect(namespaceOverlap.length).toBe(0, \
"Language namespaces are overlapping.\n\
Namespaces are unique: only one language for each namespace.\n"+
_.map(namespaceOverlap, ([namespace, group]) -> "- '#{namespace}': Check languages #{_.map(group, 'name').join(', ')} for using namespace '#{namespace}'.").join('\n')
)

View File

@ -262,13 +262,6 @@ module.exports = class Beautifiers extends EventEmitter
beautifiers = lang.beautifiers
optionName = "language_#{lang.namespace}"
# Check if namespace has already been used
if _.has(flatOptions, "#{optionName}_disabled")
error = new Error("Language named '#{name}' has an already used namespace #{lang.namespace}.")
atom.notifications?.addError(error.message, {
stack: error.stack, detail: error.message, dismissable : true})
throw error
# Add Language configurations
flatOptions["#{optionName}_disabled"] = {
title : "Language Config - #{name} - Disable Beautifying Language"