Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 44 lines (35 sloc) 0.822 kB
db9f1ed @clarkware Initial import
authored
1 #!/usr/bin/env ruby
2
3 require 'test/unit'
4
5 class OSCommandTest < Test::Unit::TestCase
6
7 def test_literal
8 result = `date`
9 assert_equal(0, exitStatus = $?)
10 regex = /(\d+):(\d+):(\d+)/
11 assert_match(regex, result)
12 end
13
14 def test_delimited_literal
15 result = %x{ date }
16 assert_equal(0, exitStatus = $?)
17 regex = /(\d+):(\d+):(\d+)/
18 assert_match(regex, result)
19 end
20
21 def test_expand_expression
22 for i in 0..3
23 result = `echo #{i}`
24 assert_equal(0, exitStatus = $?)
25 assert_equal(i.to_s, result.chomp)
26 end
27 end
28
29 def test_override_backquote
30 alias old_backquote `
31 def `(cmd)
32 result = old_backquote(cmd)
33 if $? != 0
34 fail "Command #{cmd} failed: #$?"
35 end
36 result
37 end
38
39 `date`
40 assert_equal(0, exitStatus = $?)
41 end
42
43 end
Something went wrong with that request. Please try again.