oktest 1.3.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,17 +1,21 @@
1
+ # -*- coding: utf-8 -*-
2
+ # frozen_string_literal: true
3
+
1
4
  ###
2
- ### $Release: 1.3.1 $
5
+ ### $Release: 1.5.0 $
3
6
  ### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
4
7
  ### $License: MIT License $
5
8
  ###
6
9
 
7
- require_relative './initialize'
10
+ require_relative './init'
8
11
 
9
12
  require 'stringio'
10
13
 
11
14
 
12
- class TestGenerator_TC < TC
15
+ class TestGenerator__Test
16
+ extend NanoTest
13
17
 
14
- INPUT = <<END
18
+ INPUT_3 = <<'END'
15
19
  class Hello
16
20
  def hello(name=nil)
17
21
  #; default name is 'world'.
@@ -24,10 +28,10 @@ class Hello
24
28
  end
25
29
  END
26
30
 
27
- describe '#parse()' do
28
- it "[!5mzd3] parses ruby code." do
31
+ test_target 'Oktest::TestGenerator#parse()' do
32
+ test_subject "[!5mzd3] parses ruby code." do
29
33
  g = Oktest::TestGenerator.new()
30
- tree = g.parse(StringIO.new(INPUT))
34
+ tree = g.parse(StringIO.new(INPUT_3))
31
35
  expected = [
32
36
  ["", "class", "Hello", [
33
37
  [" ", "def", "#hello", [
@@ -36,14 +40,14 @@ END
36
40
  ]]
37
41
  ]]
38
42
  ]
39
- assert_eq tree, expected
43
+ test_eq? tree, expected
40
44
  end
41
45
  end
42
46
 
43
- describe '#transform()' do
44
- it "[!te7zw] converts tree into test code." do
47
+ test_target 'Oktest::TestGenerator#transform()' do
48
+ test_subject "[!te7zw] converts tree into test code." do
45
49
  g = Oktest::TestGenerator.new()
46
- tree = g.parse(StringIO.new(INPUT))
50
+ tree = g.parse(StringIO.new(INPUT_3))
47
51
  code = g.transform(tree, 1)
48
52
  expected = <<'END'
49
53
 
@@ -56,16 +60,16 @@ END
56
60
 
57
61
  spec "returns greeting message."
58
62
 
59
- end # #hello()
63
+ end
60
64
 
61
65
 
62
66
  end # Hello
63
67
  END
64
- assert_eq code, expected
68
+ test_eq? code, expected
65
69
  end
66
- it "[!q5duk] supports 'unaryop' style option." do
70
+ test_subject "[!q5duk] supports 'unaryop' style option." do
67
71
  g = Oktest::TestGenerator.new('unaryop')
68
- tree = g.parse(StringIO.new(INPUT))
72
+ tree = g.parse(StringIO.new(INPUT_3))
69
73
  code = g.transform(tree, 1)
70
74
  expected = <<'END'
71
75
 
@@ -78,19 +82,19 @@ END
78
82
 
79
83
  - spec("returns greeting message.")
80
84
 
81
- end # #hello()
85
+ end
82
86
 
83
87
 
84
88
  end # Hello
85
89
  END
86
- assert_eq code, expected
90
+ test_eq? code, expected
87
91
  end
88
92
  end
89
93
 
90
- describe '#generate()' do
91
- it "[!5hdw4] generates test code." do
94
+ test_target 'Oktest::TestGenerator#generate()' do
95
+ test_subject "[!5hdw4] generates test code." do
92
96
  g = Oktest::TestGenerator.new()
93
- code = g.generate(StringIO.new(INPUT))
97
+ code = g.generate(StringIO.new(INPUT_3))
94
98
  expected = <<'END'
95
99
  # coding: utf-8
96
100
 
@@ -108,7 +112,7 @@ Oktest.scope do
108
112
 
109
113
  spec "returns greeting message."
110
114
 
111
- end # #hello()
115
+ end
112
116
 
113
117
 
114
118
  end # Hello
@@ -116,7 +120,7 @@ Oktest.scope do
116
120
 
117
121
  end
118
122
  END
119
- assert_eq code, expected
123
+ test_eq? code, expected
120
124
  end
121
125
  end
122
126