First Commit
This commit is contained in:
22
html/sternwarte/checkfuehrung/node_modules/cardinal/test/cardinal-highlight-block-comment.js
generated
vendored
Executable file
22
html/sternwarte/checkfuehrung/node_modules/cardinal/test/cardinal-highlight-block-comment.js
generated
vendored
Executable file
@@ -0,0 +1,22 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint-disable no-path-concat */
|
||||
|
||||
var test = require('tape')
|
||||
var fs = require('fs')
|
||||
var customTheme = require('./fixtures/custom')
|
||||
var cardinal = require('..')
|
||||
|
||||
test('\nhighlighting a block comment without line numbers', function(t) {
|
||||
var code = fs.readFileSync(__dirname + '/fixtures/block-comment.js', 'utf8')
|
||||
var highlighted = cardinal.highlight(code, { theme: customTheme })
|
||||
t.equal(highlighted, '\n\u001b[90m/**\n * This is a meaningless block jsdoc for a meaningless function.\n * Joins two strings, separating them to appear on two lines.\n * \n * @name foo\n * @function\n * @param uno {String} first string\n * @param dos {String} second string\n * @return {String} result of the join\n */\u001b[39m\n\u001b[96mmodule\u001b[39m\u001b[32m.\u001b[39m\u001b[96mexports\u001b[39m \u001b[93m=\u001b[39m \u001b[94mfunction\u001b[39m \u001b[96mfoo\u001b[39m \u001b[90m(\u001b[39m\u001b[96muno\u001b[39m\u001b[32m,\u001b[39m \u001b[96mdos\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n \u001b[31mreturn\u001b[39m \u001b[96muno\u001b[39m \u001b[93m+\u001b[39m \u001b[92m\'\\n\'\u001b[39m \u001b[93m+\u001b[39m \u001b[96mdos\u001b[39m\u001b[90m;\u001b[39m\n\u001b[33m}\u001b[39m\n')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('\nhighlighting a block comment with line numbers', function(t) {
|
||||
var code = fs.readFileSync(__dirname + '/fixtures/block-comment.js', 'utf8')
|
||||
var highlighted = cardinal.highlight(code, { theme: customTheme, linenos: true })
|
||||
t.equal(highlighted, '\u001b[90m 1: \n\u001b[90m 2: \u001b[90m/**\n\u001b[90m 3: * This is a meaningless block jsdoc for a meaningless function.\n\u001b[90m 4: * Joins two strings, separating them to appear on two lines.\n\u001b[90m 5: * \n\u001b[90m 6: * @name foo\n\u001b[90m 7: * @function\n\u001b[90m 8: * @param uno {String} first string\n\u001b[90m 9: * @param dos {String} second string\n\u001b[90m10: * @return {String} result of the join\n\u001b[90m11: */\u001b[39m\n\u001b[90m12: \u001b[96mmodule\u001b[39m\u001b[32m.\u001b[39m\u001b[96mexports\u001b[39m \u001b[93m=\u001b[39m \u001b[94mfunction\u001b[39m \u001b[96mfoo\u001b[39m \u001b[90m(\u001b[39m\u001b[96muno\u001b[39m\u001b[32m,\u001b[39m \u001b[96mdos\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m13: \u001b[31mreturn\u001b[39m \u001b[96muno\u001b[39m \u001b[93m+\u001b[39m \u001b[92m\'\\n\'\u001b[39m \u001b[93m+\u001b[39m \u001b[96mdos\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m14: \u001b[33m}\u001b[39m')
|
||||
t.end()
|
||||
})
|
||||
42
html/sternwarte/checkfuehrung/node_modules/cardinal/test/cardinal-highlight-file-async.js
generated
vendored
Executable file
42
html/sternwarte/checkfuehrung/node_modules/cardinal/test/cardinal-highlight-file-async.js
generated
vendored
Executable file
@@ -0,0 +1,42 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint-disable no-path-concat */
|
||||
|
||||
var test = require('tape')
|
||||
var path = require('path')
|
||||
var customTheme = require('./fixtures/custom')
|
||||
var cardinal = require('..')
|
||||
|
||||
var file = path.join(__dirname, 'fixtures/foo.js')
|
||||
var fileWithErrors = path.join(__dirname, 'fixtures/foo-with-errors.js')
|
||||
|
||||
test('supplying custom theme', function(t) {
|
||||
cardinal.highlightFile(file, { theme: customTheme }, function(err, highlighted) {
|
||||
t.equals(null, err, 'no error')
|
||||
t.equals(highlighted, '\u001b[94mfunction\u001b[39m \u001b[96mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \n \u001b[32mvar\u001b[39m \u001b[96ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[96ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[31mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \n\u001b[33m}\u001b[39m\n')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('not supplying custom theme', function(t) {
|
||||
cardinal.highlightFile(file, function(err, highlighted) {
|
||||
t.equals(null, err, 'no error')
|
||||
t.equals(highlighted, '\u001b[94mfunction\u001b[39m \u001b[37mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \n \u001b[32mvar\u001b[39m \u001b[37ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[91mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \n\u001b[33m}\u001b[39m\n')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('syntactically invalid code', function(t) {
|
||||
cardinal.highlightFile(fileWithErrors, function(err, highlighted) {
|
||||
t.equals(null, err, 'no error')
|
||||
t.equals(highlighted, '\u001b[94mfunction\u001b[39m \u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \n \u001b[32mvar\u001b[39m \u001b[37ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[91mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \n\u001b[33m}\u001b[39m\u001b[90m;\u001b[39m\n')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('non existing file', function(t) {
|
||||
cardinal.highlightFile('./not/existing', function(err, highlighted) {
|
||||
t.ok((/ENOENT. .*not.existing/).test(err.message))
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
40
html/sternwarte/checkfuehrung/node_modules/cardinal/test/cardinal-highlight-file-sync.js
generated
vendored
Executable file
40
html/sternwarte/checkfuehrung/node_modules/cardinal/test/cardinal-highlight-file-sync.js
generated
vendored
Executable file
@@ -0,0 +1,40 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint-disable no-path-concat */
|
||||
|
||||
var test = require('tape')
|
||||
var path = require('path')
|
||||
var customTheme = require('./fixtures/custom')
|
||||
var cardinal = require('..')
|
||||
|
||||
var file = path.join(__dirname, 'fixtures/foo.js')
|
||||
var fileWithErrors = path.join(__dirname, 'fixtures/foo-with-errors.js')
|
||||
|
||||
test('supplying custom theme', function(t) {
|
||||
var highlighted = cardinal.highlightFileSync(file, { theme: customTheme })
|
||||
|
||||
t.equals(highlighted, '\u001b[94mfunction\u001b[39m \u001b[96mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \n \u001b[32mvar\u001b[39m \u001b[96ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[96ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[31mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \n\u001b[33m}\u001b[39m\n')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('not supplying custom theme', function(t) {
|
||||
var highlighted = cardinal.highlightFileSync(file)
|
||||
|
||||
t.equals(highlighted, '\u001b[94mfunction\u001b[39m \u001b[37mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \n \u001b[32mvar\u001b[39m \u001b[37ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[91mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \n\u001b[33m}\u001b[39m\n')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('syntactically invalid code', function(t) {
|
||||
var highlighted = cardinal.highlightFileSync(fileWithErrors)
|
||||
t.equals(highlighted, '\u001b[94mfunction\u001b[39m \u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \n \u001b[32mvar\u001b[39m \u001b[37ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[91mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \n\u001b[33m}\u001b[39m\u001b[90m;\u001b[39m\n')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('non existing file', function(t) {
|
||||
try {
|
||||
cardinal.highlightFileSync('./not/existing')
|
||||
} catch (e) {
|
||||
t.ok((/ENOENT. .*not.existing/).test(e.message))
|
||||
t.end()
|
||||
}
|
||||
})
|
||||
15
html/sternwarte/checkfuehrung/node_modules/cardinal/test/cardinal-highlight-json-file-async.js
generated
vendored
Executable file
15
html/sternwarte/checkfuehrung/node_modules/cardinal/test/cardinal-highlight-json-file-async.js
generated
vendored
Executable file
@@ -0,0 +1,15 @@
|
||||
'use strict'
|
||||
|
||||
var test = require('tape')
|
||||
var path = require('path')
|
||||
var cardinal = require('..')
|
||||
|
||||
var file = path.join(__dirname, 'fixtures/json.json')
|
||||
|
||||
test('without custom theme', function(t) {
|
||||
cardinal.highlightFile(file, function(err, highlighted) {
|
||||
t.equals(null, err, 'no error')
|
||||
t.equals(highlighted, '\u001b[33m{\u001b[39m\u001b[32m"foo"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"bar"\u001b[39m\u001b[32m,\u001b[39m\u001b[32m"baz"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"quux"\u001b[39m\u001b[32m,\u001b[39m\u001b[32m"bam"\u001b[39m\u001b[93m:\u001b[39m\u001b[90mnull\u001b[39m\u001b[33m}\u001b[39m')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
14
html/sternwarte/checkfuehrung/node_modules/cardinal/test/cardinal-highlight-json-file-sync.js
generated
vendored
Executable file
14
html/sternwarte/checkfuehrung/node_modules/cardinal/test/cardinal-highlight-json-file-sync.js
generated
vendored
Executable file
@@ -0,0 +1,14 @@
|
||||
'use strict'
|
||||
|
||||
var test = require('tape')
|
||||
var path = require('path')
|
||||
var cardinal = require('..')
|
||||
|
||||
var file = path.join(__dirname, 'fixtures/json.json')
|
||||
|
||||
test('without custom theme', function(t) {
|
||||
var highlighted = cardinal.highlightFileSync(file)
|
||||
|
||||
t.equals(highlighted, '\u001b[33m{\u001b[39m\u001b[32m"foo"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"bar"\u001b[39m\u001b[32m,\u001b[39m\u001b[32m"baz"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"quux"\u001b[39m\u001b[32m,\u001b[39m\u001b[32m"bam"\u001b[39m\u001b[93m:\u001b[39m\u001b[90mnull\u001b[39m\u001b[33m}\u001b[39m')
|
||||
t.end()
|
||||
})
|
||||
32
html/sternwarte/checkfuehrung/node_modules/cardinal/test/cardinal-highlight-json.js
generated
vendored
Executable file
32
html/sternwarte/checkfuehrung/node_modules/cardinal/test/cardinal-highlight-json.js
generated
vendored
Executable file
@@ -0,0 +1,32 @@
|
||||
'use strict'
|
||||
|
||||
var test = require('tape')
|
||||
var customTheme = require('./fixtures/custom')
|
||||
var cardinal = require('..')
|
||||
|
||||
var json = JSON.stringify({
|
||||
foo: 'bar',
|
||||
baz: 'quux',
|
||||
bam: null
|
||||
})
|
||||
|
||||
test('supplying custom theme', function(t) {
|
||||
var highlighted = cardinal.highlight(json, { theme: customTheme })
|
||||
|
||||
t.equals(highlighted, '\u001b[33m{\u001b[39m\u001b[92m"foo"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"bar"\u001b[39m\u001b[32m,\u001b[39m\u001b[92m"baz"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"quux"\u001b[39m\u001b[32m,\u001b[39m\u001b[92m"bam"\u001b[39m\u001b[93m:\u001b[39m\u001b[90mnull\u001b[39m\u001b[33m}\u001b[39m')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('not supplying custom theme', function(t) {
|
||||
var highlighted = cardinal.highlight(json)
|
||||
|
||||
t.equals(highlighted, '\u001b[33m{\u001b[39m\u001b[32m"foo"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"bar"\u001b[39m\u001b[32m,\u001b[39m\u001b[32m"baz"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"quux"\u001b[39m\u001b[32m,\u001b[39m\u001b[32m"bam"\u001b[39m\u001b[93m:\u001b[39m\u001b[90mnull\u001b[39m\u001b[33m}\u001b[39m')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('with the obsoleted json option (ignored)', function(t) {
|
||||
var highlighted = cardinal.highlight(json, { json: true })
|
||||
|
||||
t.equals(highlighted, '\u001b[33m{\u001b[39m\u001b[32m"foo"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"bar"\u001b[39m\u001b[32m,\u001b[39m\u001b[32m"baz"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"quux"\u001b[39m\u001b[32m,\u001b[39m\u001b[32m"bam"\u001b[39m\u001b[93m:\u001b[39m\u001b[90mnull\u001b[39m\u001b[33m}\u001b[39m')
|
||||
t.end()
|
||||
})
|
||||
61
html/sternwarte/checkfuehrung/node_modules/cardinal/test/cardinal-highlight-string.js
generated
vendored
Executable file
61
html/sternwarte/checkfuehrung/node_modules/cardinal/test/cardinal-highlight-string.js
generated
vendored
Executable file
@@ -0,0 +1,61 @@
|
||||
'use strict'
|
||||
|
||||
var test = require('tape')
|
||||
var customTheme = require('./fixtures/custom')
|
||||
var cardinal = require('..')
|
||||
|
||||
var code = 'function foo() { var a = 3; return a > 2 ? true : false; }'
|
||||
var codeWithErrors = 'function () { var a = 3; return a > 2 ? true : false; }'
|
||||
|
||||
test('supplying custom theme', function(t) {
|
||||
var highlighted = cardinal.highlight(code, { theme: customTheme })
|
||||
|
||||
t.equals(highlighted, '\u001b[94mfunction\u001b[39m \u001b[96mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \u001b[32mvar\u001b[39m \u001b[96ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[96ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[31mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \u001b[33m}\u001b[39m')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('not supplying custom theme', function(t) {
|
||||
var highlighted = cardinal.highlight(code)
|
||||
|
||||
t.equals(highlighted, '\u001b[94mfunction\u001b[39m \u001b[37mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \u001b[32mvar\u001b[39m \u001b[37ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[91mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \u001b[33m}\u001b[39m')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('syntactically invalid code', function(t) {
|
||||
var highlighted = cardinal.highlight(codeWithErrors)
|
||||
|
||||
t.equals(highlighted, '\u001b[94mfunction\u001b[39m \u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \u001b[32mvar\u001b[39m \u001b[37ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[91mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \u001b[33m}\u001b[39m')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('line numbers no firstline given', function(t) {
|
||||
var highlighted = cardinal.highlight(code, { linenos: true })
|
||||
t.equals(highlighted, '\u001b[90m1: \u001b[94mfunction\u001b[39m \u001b[37mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \u001b[32mvar\u001b[39m \u001b[37ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[91mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \u001b[33m}\u001b[39m')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('line numbers firstline 99', function(t) {
|
||||
var highlighted = cardinal.highlight(code, { linenos: true, firstline: 99 })
|
||||
t.equals(highlighted, '\u001b[90m99: \u001b[94mfunction\u001b[39m \u001b[37mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m \u001b[32mvar\u001b[39m \u001b[37ma\u001b[39m \u001b[93m=\u001b[39m \u001b[34m3\u001b[39m\u001b[90m;\u001b[39m \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m>\u001b[39m \u001b[34m2\u001b[39m \u001b[93m?\u001b[39m \u001b[91mtrue\u001b[39m \u001b[93m:\u001b[39m \u001b[91mfalse\u001b[39m\u001b[90m;\u001b[39m \u001b[33m}\u001b[39m')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('line numbers multi line no first line given', function(t) {
|
||||
var multilineCode = '' +
|
||||
function foo() {
|
||||
return 1
|
||||
}
|
||||
var highlighted = cardinal.highlight(multilineCode, { linenos: true })
|
||||
t.equals(highlighted, '\u001b[90m1: \u001b[94mfunction\u001b[39m \u001b[37mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m2: \u001b[31mreturn\u001b[39m \u001b[34m1\u001b[39m\n\u001b[90m3: \u001b[33m}\u001b[39m')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('line numbers multi line first line 99', function(t) {
|
||||
var multilineCode = '' +
|
||||
function foo() {
|
||||
return 1
|
||||
}
|
||||
var highlighted = cardinal.highlight(multilineCode, { linenos: true, firstline: 99 })
|
||||
t.equals(highlighted, '\u001b[90m 99: \u001b[94mfunction\u001b[39m \u001b[37mfoo\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m100: \u001b[31mreturn\u001b[39m \u001b[34m1\u001b[39m\n\u001b[90m101: \u001b[33m}\u001b[39m')
|
||||
t.end()
|
||||
})
|
||||
37
html/sternwarte/checkfuehrung/node_modules/cardinal/test/cardinal-smoke.js
generated
vendored
Executable file
37
html/sternwarte/checkfuehrung/node_modules/cardinal/test/cardinal-smoke.js
generated
vendored
Executable file
@@ -0,0 +1,37 @@
|
||||
'use strict'
|
||||
|
||||
// applying esprima to a bunch of files of contained libraries as a smoke test
|
||||
var test = require('tape')
|
||||
var path = require('path')
|
||||
var fs = require('fs')
|
||||
var readdirp = require('readdirp')
|
||||
var cardinal = require('..')
|
||||
var nodeModules = path.join(__dirname, '..', 'node_modules')
|
||||
var tapedir = path.join(nodeModules, 'tape')
|
||||
var redeyeddir = path.join(nodeModules, 'redeyed')
|
||||
|
||||
test('tape', function(t) {
|
||||
readdirp({ root: tapedir, fileFilter: '*.js' })
|
||||
.on('data', function(entry) {
|
||||
var code = fs.readFileSync(entry.fullPath, 'utf-8')
|
||||
var result = cardinal.highlight(code)
|
||||
|
||||
if (!(/^[^/*]*var /.test(code))) {
|
||||
t.pass('skipping ' + entry.path + ' due to missing var statement')
|
||||
} else {
|
||||
t.assert(~result.indexOf('[32mvar\u001b[39m'), 'highlighted ' + entry.path)
|
||||
}
|
||||
})
|
||||
.on('end', t.end.bind(t))
|
||||
})
|
||||
|
||||
test('redeyed', function(t) {
|
||||
readdirp({ root: redeyeddir, fileFilter: 'redeyed.js' })
|
||||
.on('data', function(entry) {
|
||||
var code = fs.readFileSync(entry.fullPath, 'utf-8')
|
||||
var result = cardinal.highlight(code)
|
||||
|
||||
t.assert(~result.indexOf('[32mvar\u001b[39m') || !(~result.indexOf('var ')), 'highlighted ' + entry.path)
|
||||
})
|
||||
.on('end', t.end.bind(t))
|
||||
})
|
||||
14
html/sternwarte/checkfuehrung/node_modules/cardinal/test/fixtures/block-comment.js
generated
vendored
Executable file
14
html/sternwarte/checkfuehrung/node_modules/cardinal/test/fixtures/block-comment.js
generated
vendored
Executable file
@@ -0,0 +1,14 @@
|
||||
|
||||
/**
|
||||
* This is a meaningless block jsdoc for a meaningless function.
|
||||
* Joins two strings, separating them to appear on two lines.
|
||||
*
|
||||
* @name foo
|
||||
* @function
|
||||
* @param uno {String} first string
|
||||
* @param dos {String} second string
|
||||
* @return {String} result of the join
|
||||
*/
|
||||
module.exports = function foo (uno, dos) {
|
||||
return uno + '\n' + dos;
|
||||
}
|
||||
144
html/sternwarte/checkfuehrung/node_modules/cardinal/test/fixtures/custom.js
generated
vendored
Executable file
144
html/sternwarte/checkfuehrung/node_modules/cardinal/test/fixtures/custom.js
generated
vendored
Executable file
@@ -0,0 +1,144 @@
|
||||
var colors = require('ansicolors');
|
||||
|
||||
// Change the below definitions in order to tweak the color theme.
|
||||
module.exports = {
|
||||
|
||||
'Boolean': {
|
||||
// changed from default
|
||||
'true' : colors.red
|
||||
|
||||
, 'false' : undefined
|
||||
, _default : colors.brightRed
|
||||
}
|
||||
|
||||
, 'Identifier': {
|
||||
'undefined' : colors.brightBlack
|
||||
, 'self' : colors.brightRed
|
||||
, 'console' : colors.blue
|
||||
, 'log' : colors.blue
|
||||
, 'warn' : colors.red
|
||||
, 'error' : colors.brightRed
|
||||
//
|
||||
// changed from default
|
||||
, _default : colors.brightCyan
|
||||
}
|
||||
|
||||
, 'Null': {
|
||||
_default: colors.brightBlack
|
||||
}
|
||||
|
||||
, 'Numeric': {
|
||||
_default: colors.blue
|
||||
}
|
||||
|
||||
, 'String': {
|
||||
_default: colors.brightGreen
|
||||
}
|
||||
|
||||
, 'Keyword': {
|
||||
'break' : undefined
|
||||
|
||||
, 'case' : undefined
|
||||
, 'catch' : colors.cyan
|
||||
, 'continue' : undefined
|
||||
|
||||
, 'debugger' : undefined
|
||||
, 'default' : undefined
|
||||
, 'delete' : colors.red
|
||||
, 'do' : undefined
|
||||
|
||||
, 'else' : undefined
|
||||
|
||||
, 'finally' : colors.cyan
|
||||
, 'for' : undefined
|
||||
, 'function' : undefined
|
||||
|
||||
, 'if' : undefined
|
||||
, 'in' : undefined
|
||||
, 'instanceof' : undefined
|
||||
|
||||
, 'new' : colors.red
|
||||
, 'return' : colors.red
|
||||
, 'switch' : undefined
|
||||
|
||||
, 'this' : colors.brightRed
|
||||
, 'throw' : undefined
|
||||
, 'try' : colors.cyan
|
||||
, 'typeof' : undefined
|
||||
|
||||
, 'var' : colors.green
|
||||
, 'void' : undefined
|
||||
|
||||
, 'while' : undefined
|
||||
, 'with' : undefined
|
||||
, _default : colors.brightBlue
|
||||
}
|
||||
, 'Punctuator': {
|
||||
';': colors.brightBlack
|
||||
, '.': colors.green
|
||||
, ',': colors.green
|
||||
|
||||
, '{': colors.yellow
|
||||
, '}': colors.yellow
|
||||
, '(': colors.brightBlack
|
||||
, ')': colors.brightBlack
|
||||
, '[': colors.yellow
|
||||
, ']': colors.yellow
|
||||
|
||||
, '<': undefined
|
||||
, '>': undefined
|
||||
, '+': undefined
|
||||
, '-': undefined
|
||||
, '*': undefined
|
||||
, '%': undefined
|
||||
, '&': undefined
|
||||
, '|': undefined
|
||||
, '^': undefined
|
||||
, '!': undefined
|
||||
, '~': undefined
|
||||
, '?': undefined
|
||||
, ':': undefined
|
||||
, '=': undefined
|
||||
|
||||
, '<=': undefined
|
||||
, '>=': undefined
|
||||
, '==': undefined
|
||||
, '!=': undefined
|
||||
, '++': undefined
|
||||
, '--': undefined
|
||||
, '<<': undefined
|
||||
, '>>': undefined
|
||||
, '&&': undefined
|
||||
, '||': undefined
|
||||
, '+=': undefined
|
||||
, '-=': undefined
|
||||
, '*=': undefined
|
||||
, '%=': undefined
|
||||
, '&=': undefined
|
||||
, '|=': undefined
|
||||
, '^=': undefined
|
||||
, '/=': undefined
|
||||
|
||||
, '===': undefined
|
||||
, '!==': undefined
|
||||
, '>>>': undefined
|
||||
, '<<=': undefined
|
||||
, '>>=': undefined
|
||||
|
||||
, '>>>=': undefined
|
||||
|
||||
, _default: colors.brightYellow
|
||||
}
|
||||
|
||||
// line comment
|
||||
, Line: {
|
||||
_default: colors.brightBlack
|
||||
}
|
||||
|
||||
/* block comment */
|
||||
, Block: {
|
||||
_default: colors.brightBlack
|
||||
}
|
||||
|
||||
, _default: undefined
|
||||
};
|
||||
3
html/sternwarte/checkfuehrung/node_modules/cardinal/test/fixtures/foo-with-errors.js
generated
vendored
Executable file
3
html/sternwarte/checkfuehrung/node_modules/cardinal/test/fixtures/foo-with-errors.js
generated
vendored
Executable file
@@ -0,0 +1,3 @@
|
||||
function () {
|
||||
var a = 3; return a > 2 ? true : false;
|
||||
};
|
||||
3
html/sternwarte/checkfuehrung/node_modules/cardinal/test/fixtures/foo.js
generated
vendored
Executable file
3
html/sternwarte/checkfuehrung/node_modules/cardinal/test/fixtures/foo.js
generated
vendored
Executable file
@@ -0,0 +1,3 @@
|
||||
function foo() {
|
||||
var a = 3; return a > 2 ? true : false;
|
||||
}
|
||||
1
html/sternwarte/checkfuehrung/node_modules/cardinal/test/fixtures/json.json
generated
vendored
Executable file
1
html/sternwarte/checkfuehrung/node_modules/cardinal/test/fixtures/json.json
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"foo":"bar","baz":"quux","bam":null}
|
||||
23
html/sternwarte/checkfuehrung/node_modules/cardinal/test/fixtures/svn-diff.txt
generated
vendored
Executable file
23
html/sternwarte/checkfuehrung/node_modules/cardinal/test/fixtures/svn-diff.txt
generated
vendored
Executable file
@@ -0,0 +1,23 @@
|
||||
Index: grunt.js
|
||||
===================================================================
|
||||
--- grunt.js (revision 31200)
|
||||
+++ grunt.js (working copy)
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
module.exports = function (grunt) {
|
||||
|
||||
+ console.log('hello world');
|
||||
// Project configuration.
|
||||
grunt.initConfig({
|
||||
lint: {
|
||||
@@ -19,10 +20,6 @@
|
||||
'packages/services.web/{!(test)/**/,}*.js',
|
||||
'packages/error/**/*.js'
|
||||
],
|
||||
- scripts: [
|
||||
- 'grunt.js',
|
||||
- 'db/**/*.js'
|
||||
- ],
|
||||
browser: [
|
||||
'packages/web/server.js',
|
||||
'packages/web/server/**/*.js',
|
||||
77
html/sternwarte/checkfuehrung/node_modules/cardinal/test/settings.js
generated
vendored
Executable file
77
html/sternwarte/checkfuehrung/node_modules/cardinal/test/settings.js
generated
vendored
Executable file
@@ -0,0 +1,77 @@
|
||||
'use strict'
|
||||
/* jshint asi: true */
|
||||
|
||||
var test = require('tape')
|
||||
var path = require('path')
|
||||
var fs = require('fs')
|
||||
var hideSemicolonsTheme = require('../themes/hide-semicolons')
|
||||
var home = path.join(__dirname, 'fixtures', 'home')
|
||||
var rcpath = path.join(home, '.cardinalrc')
|
||||
var existsSync = fs.existsSync || path.existsSync
|
||||
var settingsResolve = require.resolve('../settings')
|
||||
var settings
|
||||
|
||||
function setup() {
|
||||
delete require.cache[settingsResolve]
|
||||
settings = require(settingsResolve)
|
||||
}
|
||||
|
||||
function writerc(config) {
|
||||
fs.writeFileSync(rcpath, JSON.stringify(config), 'utf-8')
|
||||
}
|
||||
|
||||
function removerc() {
|
||||
fs.unlinkSync(rcpath)
|
||||
}
|
||||
|
||||
function resolveTheme(config) {
|
||||
writerc(config)
|
||||
var result = settings.resolveTheme(home)
|
||||
removerc()
|
||||
return result
|
||||
}
|
||||
|
||||
function getSettings(config) {
|
||||
writerc(config)
|
||||
var result = settings.getSettings(home)
|
||||
removerc()
|
||||
return result
|
||||
}
|
||||
|
||||
if (!existsSync(home)) fs.mkdirSync(home)
|
||||
|
||||
test('no .cardinalrc in home', function(t) {
|
||||
setup()
|
||||
var theme = settings.resolveTheme(home)
|
||||
t.equals(theme, undefined, 'resolves no theme')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('.cardinalrc with theme "hide-semicolons" in home', function(t) {
|
||||
setup()
|
||||
var theme = resolveTheme({ theme: 'hide-semicolons' })
|
||||
t.deepEquals(theme, hideSemicolonsTheme, 'resolves hide-semicolons theme')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('.cardinalrc with full path to "hide-semicolons.js" in home', function(t) {
|
||||
setup()
|
||||
var theme = resolveTheme({ theme: path.join(__dirname, '..', 'themes', 'hide-semicolons.js') })
|
||||
t.deepEquals(theme, hideSemicolonsTheme, 'resolves hide-semicolons theme')
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('.cardinalrc with linenos: true', function(t) {
|
||||
setup()
|
||||
var opts = { linenos: true }
|
||||
t.deepEquals(getSettings(opts), opts)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('.cardinalrc with linenos: true and theme', function(t) {
|
||||
setup()
|
||||
var opts = { linenos: true, theme: 'some theme' }
|
||||
t.deepEquals(getSettings(opts), opts)
|
||||
t.end()
|
||||
})
|
||||
|
||||
22
html/sternwarte/checkfuehrung/node_modules/cardinal/test/themes.js
generated
vendored
Executable file
22
html/sternwarte/checkfuehrung/node_modules/cardinal/test/themes.js
generated
vendored
Executable file
@@ -0,0 +1,22 @@
|
||||
'use strict'
|
||||
/* jshint asi: true */
|
||||
|
||||
var test = require('tape')
|
||||
var path = require('path')
|
||||
var fs = require('fs')
|
||||
var themesdir = path.join(__dirname, '..', 'themes')
|
||||
var allFiles = fs.readdirSync(themesdir)
|
||||
|
||||
test('validate themes by requiring all of them', function(t) {
|
||||
allFiles
|
||||
.filter(function(file) { return path.extname(file) === '.js' })
|
||||
.forEach(function(theme) {
|
||||
try {
|
||||
t.ok(require(path.join(themesdir, theme)), theme + ' is valid')
|
||||
} catch (e) {
|
||||
t.fail('theme: ' + theme + ' is invalid! ' + e.message)
|
||||
}
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user