Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/utils/tests/serverjs/file/extension.js
blob: 00e5959c92f4786274ac95b39f6c9b2c77ec1844 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

var util = require('util');
var assert = require('test/assert');
var fs = require('file');

util.forEachApply([
    ['', ''],
    ['.', ''],
    ['..', ''],
    ['.a', ''],
    ['..a', ''],
    ['.a.b', '.b'],
    ['a.b', '.b'],
    ['a.b.c', '.c'],
    ['/', ''],
    ['/.', ''],
    ['/..', ''],
    ['/..a', ''],
    ['/.a.b', '.b'],
    ['/a.b', '.b'],
    ['/a.b.c', '.c'],
    ['foo/', ''],
    ['foo/.', ''],
    ['foo/..', ''],
    ['foo/..a', ''],
    ['foo/.a.b', '.b'],
    ['foo/a.b', '.b'],
    ['foo/a.b.c', '.c'],
    ['/foo/', ''],
    ['/foo/.', ''],
    ['/foo/..', ''],
    ['/foo/..a', ''],
    ['/foo/.a.b', '.b'],
    ['/foo/a.b', '.b'],
    ['/foo/a.b.c', '.c']
], function (path, expected) {
    exports['test ' + util.repr(path)] = function () {
        var actual = fs.extension(path);
        assert.eq(expected, actual, util.repr(path));
    };
});

if (require.main === module.id)
    require("os").exit(require("test/runner").run(exports));