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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
|
Feature: Basic Calculator Functions
In order to check I've written the Calculator class correctly
As a developer I want to check some basic operations
So that I can have confidence in my Calculator class.
Background:
Given a usable "Calculator" class
Scenario: First Key Press on the Display
Given a new Calculator object
And having pressed 1
Then the display should show 1
Scenario: Several Key Presses on the Display
Given a new Calculator object
And having pressed 1 and 2 and 3 and . and 5 and 0
Then the display should show 123.50
Scenario: Pressing Clear Wipes the Display
Given a new Calculator object
And having pressed 1 and 2 and 3
And having pressed C
Then the display should show 0
Scenario: Add as you go
Given a new Calculator object
And having pressed 1 and 2 and 3 and + and 4 and 5 and 6 and +
Then the display should show 579
Scenario: Basic arithmetic
Given a new Calculator object
And having keyed <first>
And having keyed <operator>
And having keyed <second>
And having pressed =
Then the display should show <result>
Examples:
| first | operator | second | result |
| 5.0 | + | 5.0 | 10 |
| 6 | / | 3 | 2 |
| 10 | * | 7.550 | 75.5 |
| 3 | - | 10 | -7 |
Scenario: Separation of calculations
Given a new Calculator object
And having successfully performed the following calculations
| first | operator | second | result |
| 0.5 | + | 0.1 | 0.6 |
| 0.01 | / | 0.01 | 1 |
| 10 | * | 1 | 10 |
And having pressed 3
Then the display should show 3
Scenario: Ticker Tape
Given a new Calculator object
And having entered the following sequence
"""
1 + 2 + 3 + 4 + 5 + 6 -
100
* 13 \=\=\= + 2 =
"""
Then the display should show -1025
----------DIVIDER----------
---
line: 1
name: Basic Calculator Functions
satisfaction:
- In order to check I've written the Calculator class correctly
- As a developer I want to check some basic operations
- So that I can have confidence in my Calculator class.
scenarios:
-
background: 0
data: []
line: 9
name: First Key Press on the Display
steps:
-
data: ~
line: 10
text: a new Calculator object
verb: Given
verb_original: Given
-
data: ~
line: 11
text: having pressed 1
verb: Given
verb_original: And
-
data: ~
line: 12
text: the display should show 1
verb: Then
verb_original: Then
-
background: 0
data: []
line: 14
name: Several Key Presses on the Display
steps:
-
data: ~
line: 15
text: a new Calculator object
verb: Given
verb_original: Given
-
data: ~
line: 16
text: having pressed 1 and 2 and 3 and . and 5 and 0
verb: Given
verb_original: And
-
data: ~
line: 17
text: the display should show 123.50
verb: Then
verb_original: Then
-
background: 0
data: []
line: 19
name: Pressing Clear Wipes the Display
steps:
-
data: ~
line: 20
text: a new Calculator object
verb: Given
verb_original: Given
-
data: ~
line: 21
text: having pressed 1 and 2 and 3
verb: Given
verb_original: And
-
data: ~
line: 22
text: having pressed C
verb: Given
verb_original: And
-
data: ~
line: 23
text: the display should show 0
verb: Then
verb_original: Then
-
background: 0
data: []
line: 25
name: Add as you go
steps:
-
data: ~
line: 26
text: a new Calculator object
verb: Given
verb_original: Given
-
data: ~
line: 27
text: having pressed 1 and 2 and 3 and + and 4 and 5 and 6 and +
verb: Given
verb_original: And
-
data: ~
line: 28
text: the display should show 579
verb: Then
verb_original: Then
-
background: 0
data:
-
first: '5.0'
operator: +
result: 10
second: '5.0'
-
first: 6
operator: /
result: 2
second: 3
-
first: 10
operator: "*"
result: '75.5'
second: '7.550'
-
first: 3
operator: "-"
result: -7
second: 10
line: 30
name: Basic arithmetic
steps:
-
data: ~
line: 31
text: a new Calculator object
verb: Given
verb_original: Given
-
data: ~
line: 32
text: having keyed <first>
verb: Given
verb_original: And
-
data: ~
line: 33
text: having keyed <operator>
verb: Given
verb_original: And
-
data: ~
line: 34
text: having keyed <second>
verb: Given
verb_original: And
-
data: ~
line: 35
text: having pressed =
verb: Given
verb_original: And
-
data: ~
line: 36
text: the display should show <result>
verb: Then
verb_original: Then
-
background: 0
data: []
line: 44
name: Separation of calculations
steps:
-
data: ~
line: 45
text: a new Calculator object
verb: Given
verb_original: Given
-
data:
-
first: '0.5'
operator: +
result: '0.6'
second: '0.1'
-
first: '0.01'
operator: /
result: 1
second: '0.01'
-
first: 10
operator: "*"
result: 10
second: 1
line: 46
text: having successfully performed the following calculations
verb: Given
verb_original: And
-
data: ~
line: 51
text: having pressed 3
verb: Given
verb_original: And
-
data: ~
line: 52
text: the display should show 3
verb: Then
verb_original: Then
-
background: 0
data: []
line: 54
name: Ticker Tape
steps:
-
data: ~
line: 55
text: a new Calculator object
verb: Given
verb_original: Given
-
data: "1 + 2 + 3 + 4 + 5 + 6 -\n100\n* 13 === + 2 =\n"
line: 56
text: having entered the following sequence
verb: Given
verb_original: And
-
data: ~
line: 62
text: the display should show -1025
verb: Then
verb_original: Then
|