~ubuntu-branches/ubuntu/oneiric/rake/oneiric

« back to all changes in this revision

Viewing changes to test/test_pathmap.rb

  • Committer: Bazaar Package Importer
  • Author(s): Adam Majer
  • Date: 2007-05-06 17:15:36 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070506171536-qy40vbx5a248gsak
Tags: 0.7.3-1
* New upstream release
* Updated flexmock from 0.1.7 to 0.6.0
* Updated Standards to 0.7.2 - no changes
* Fixed Build-Depends on debhelper

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
  def test_s_returns_file_separator
14
14
    sep = File::ALT_SEPARATOR || File::SEPARATOR
15
15
    assert_equal sep, "abc.rb".pathmap("%s")
 
16
    assert_equal sep, "".pathmap("%s")
16
17
    assert_equal "a#{sep}b", "a/b".pathmap("%d%s%f")
17
18
  end
18
19
 
19
 
  def test_b_returns_basename
 
20
  def test_f_returns_basename
20
21
    assert_equal "abc.rb", "abc.rb".pathmap("%f")
21
22
    assert_equal "abc.rb", "this/is/a/dir/abc.rb".pathmap("%f")
22
23
    assert_equal "abc.rb", "/this/is/a/dir/abc.rb".pathmap("%f")
23
24
  end
24
25
 
25
 
  def test_B_returns_basename_without_extension
 
26
  def test_n_returns_basename_without_extension
26
27
    assert_equal "abc", "abc.rb".pathmap("%n")
27
28
    assert_equal "abc", "abc".pathmap("%n") 
28
29
    assert_equal "abc", "this/is/a/dir/abc.rb".pathmap("%n")
37
38
    assert_equal "/this/is/a/dir", "/this/is/a/dir/abc.rb".pathmap("%d")
38
39
  end
39
40
 
40
 
  def test_nnnd_returns_partial_dirname
 
41
  def test_9d_returns_partial_dirname
41
42
    assert_equal "this/is", "this/is/a/dir/abc.rb".pathmap("%2d")
42
43
    assert_equal "this", "this/is/a/dir/abc.rb".pathmap("%1d")
43
44
    assert_equal ".", "this/is/a/dir/abc.rb".pathmap("%0d")
47
48
    assert_equal "this/is/a/dir", "this/is/a/dir/abc.rb".pathmap("%-100d")
48
49
  end
49
50
 
 
51
  def test_x_returns_extension
 
52
    assert_equal "", "abc".pathmap("%x")
 
53
    assert_equal ".rb", "abc.rb".pathmap("%x")
 
54
    assert_equal ".rb", "abc.xyz.rb".pathmap("%x")
 
55
    assert_equal "", ".depends".pathmap("%x")
 
56
    assert_equal "", "dir/.depends".pathmap("%x")
 
57
  end
 
58
 
 
59
  def test_X_returns_everything_but_extension
 
60
    assert_equal "abc", "abc".pathmap("%X")
 
61
    assert_equal "abc", "abc.rb".pathmap("%X")
 
62
    assert_equal "abc.xyz", "abc.xyz.rb".pathmap("%X")
 
63
    assert_equal ".depends", ".depends".pathmap("%X")
 
64
    assert_equal "a/dir/.depends", "a/dir/.depends".pathmap("%X")
 
65
    assert_equal "/.depends", "/.depends".pathmap("%X")
 
66
  end
 
67
 
 
68
  def test_p_returns_entire_pathname
 
69
    assert_equal "abc.rb", "abc.rb".pathmap("%p")
 
70
    assert_equal "this/is/a/dir/abc.rb", "this/is/a/dir/abc.rb".pathmap("%p")
 
71
    assert_equal "/this/is/a/dir/abc.rb", "/this/is/a/dir/abc.rb".pathmap("%p")
 
72
  end
 
73
 
 
74
  def test_dash_returns_empty_string
 
75
    assert_equal "", "abc.rb".pathmap("%-")
 
76
    assert_equal "abc.rb", "abc.rb".pathmap("%X%-%x")
 
77
  end
 
78
 
 
79
  def test_percent_percent_returns_percent
 
80
    assert_equal "a%b", "".pathmap("a%%b")
 
81
  end
 
82
 
 
83
  def test_undefined_percent_causes_error
 
84
    ex = assert_raise(ArgumentError) {
 
85
      "dir/abc.rb".pathmap("%z")
 
86
    }
 
87
  end
 
88
 
50
89
  def test_pattern_returns_substitutions
51
90
    assert_equal "bin/org/osb",
52
91
      "src/org/osb/Xyz.java".pathmap("%{src,bin}d")
92
131
    assert_match(/unknown.*pathmap.*spec.*z/i, ex.message)
93
132
  end
94
133
 
95
 
  def test_x_returns_extension
96
 
    assert_equal "", "abc".pathmap("%x")
97
 
    assert_equal ".rb", "abc.rb".pathmap("%x")
98
 
    assert_equal ".rb", "abc.xyz.rb".pathmap("%x")
99
 
    assert_equal "", ".depends".pathmap("%x")
100
 
    assert_equal "", "dir/.depends".pathmap("%x")
101
 
  end
102
 
 
103
 
  def test_X_returns_everything_but_extension
104
 
    assert_equal "abc", "abc".pathmap("%X")
105
 
    assert_equal "abc", "abc.rb".pathmap("%X")
106
 
    assert_equal "abc.xyz", "abc.xyz.rb".pathmap("%X")
107
 
    assert_equal ".depends", ".depends".pathmap("%X")
108
 
    assert_equal "a/dir/.depends", "a/dir/.depends".pathmap("%X")
109
 
    assert_equal "/.depends", "/.depends".pathmap("%X")
110
 
  end
111
 
 
112
 
  def test_p_returns_entire_pathname
113
 
    assert_equal "abc.rb", "abc.rb".pathmap("%p")
114
 
    assert_equal "this/is/a/dir/abc.rb", "this/is/a/dir/abc.rb".pathmap("%p")
115
 
    assert_equal "/this/is/a/dir/abc.rb", "/this/is/a/dir/abc.rb".pathmap("%p")
116
 
  end
117
 
 
118
 
  def test_percent_percent_returns_percent
119
 
    assert_equal "a%b", "".pathmap("a%%b")
120
 
  end
121
 
 
122
 
  def test_undefined_percent_causes_error
123
 
    ex = assert_raise(ArgumentError) {
124
 
      "dir/abc.rb".pathmap("%z")
125
 
    }
126
 
  end
127
 
 
128
134
  def test_works_with_windows_separators
129
135
    if File::ALT_SEPARATOR
130
136
      assert_equal "abc", 'dir\abc.rb'.pathmap("%n")