skeem 0.2.21 → 0.2.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,7 @@ module Skeem
10
10
  describe 'Testing primitive procedures' do
11
11
  include InterpreterSpec
12
12
 
13
- subject do
13
+ subject(:builder) do
14
14
  # We load the interpreter with the primitive procedures only
15
15
  Interpreter.new { |interp| interp.add_primitives(interp.runtime) }
16
16
  end
@@ -20,25 +20,25 @@ module Skeem
20
20
  end
21
21
 
22
22
  context 'Arithmetic operators:' do
23
- it 'should implement the set! form' do
23
+ it 'implements the set! form' do
24
24
  skeem1 = <<-SKEEM
25
25
  (define x 2)
26
26
  (+ x 1)
27
27
  SKEEM
28
- result = subject.run(skeem1)
28
+ result = builder.run(skeem1)
29
29
  expect(result.last).to eq(3) # x is bound to value 2
30
30
 
31
31
  skeem2 = <<-SKEEM
32
32
  (set! x 4)
33
33
  (+ x 1)
34
34
  SKEEM
35
- result = subject.run(skeem2)
35
+ result = builder.run(skeem2)
36
36
  expect(result.last).to eq(5) # x is now bound to value 4
37
37
  end
38
38
  end # context
39
39
 
40
40
  context 'Arithmetic operators:' do
41
- it 'should implement the addition operator' do
41
+ it 'implements the addition operator' do
42
42
  checks = [
43
43
  ['(+)', 0], # '+' as nullary operator. Example from section 6.2.6
44
44
  ['(+ -3)', -3], # '+' as unary operator
@@ -50,7 +50,7 @@ SKEEM
50
50
  compare_to_predicted(checks)
51
51
  end
52
52
 
53
- it 'should implement the minus operator' do
53
+ it 'implements the minus operator' do
54
54
  checks = [
55
55
  ['(- 3)', -3], # '-' as unary operator (= sign change)
56
56
  ['(- -2/3)', Rational(2, 3)],
@@ -60,7 +60,7 @@ SKEEM
60
60
  compare_to_predicted(checks)
61
61
  end
62
62
 
63
- it 'should implement the product operator' do
63
+ it 'implements the product operator' do
64
64
  checks = [
65
65
  ['(*)', 1], # '*' as nullary operator. Example from section 6.2.6
66
66
  ['(* 4)', 4], # '*' as unary operator. Example from section 6.2.6
@@ -71,7 +71,7 @@ SKEEM
71
71
  compare_to_predicted(checks)
72
72
  end
73
73
 
74
- it 'should implement the division operator' do
74
+ it 'implements the division operator' do
75
75
  checks = [
76
76
  ['(/ 3)', Rational(1, 3)], # '/' as unary operator (= inverse of argument)
77
77
  ['(/ 3/4)', Rational(4, 3)],
@@ -81,11 +81,11 @@ SKEEM
81
81
  ]
82
82
  compare_to_predicted(checks)
83
83
 
84
- result = subject.run('(/ 3 4.5)')
84
+ result = builder.run('(/ 3 4.5)')
85
85
  expect(result.value).to be_within(0.000001).of(0.66666667)
86
86
  end
87
87
 
88
- it 'should implement the floor/ procedure' do
88
+ it 'implements the floor/ procedure' do
89
89
  checks = [
90
90
  ['(floor/ 5 2)', [2, 1]], # Binary procedure.
91
91
  ['(floor/ -5 2)', [-3, 1]],
@@ -97,7 +97,7 @@ SKEEM
97
97
  end
98
98
  end
99
99
 
100
- it 'should implement the truncate/ procedure' do
100
+ it 'implements the truncate/ procedure' do
101
101
  checks = [
102
102
  ['(truncate/ 5 2)', [2, 1]], # Binary procedure.
103
103
  ['(truncate/ -5 2)', [-2, -1]],
@@ -109,7 +109,7 @@ SKEEM
109
109
  end
110
110
  end
111
111
 
112
- it 'should implement the gcd procedure' do
112
+ it 'implements the gcd procedure' do
113
113
  checks = [
114
114
  ['(gcd)', 0],
115
115
  ['(gcd 47)', 47],
@@ -120,7 +120,7 @@ SKEEM
120
120
  compare_to_predicted(checks)
121
121
  end
122
122
 
123
- it 'should implement the lcm procedure' do
123
+ it 'implements the lcm procedure' do
124
124
  checks = [
125
125
  ['(lcm)', 1],
126
126
  ['(lcm 47)', 47],
@@ -132,21 +132,21 @@ SKEEM
132
132
  compare_to_predicted(checks)
133
133
  end
134
134
 
135
- it 'should implement the numerator procedure' do
135
+ it 'implements the numerator procedure' do
136
136
  checks = [
137
137
  ['(numerator (/ 6 4))', 3]
138
138
  ]
139
139
  compare_to_predicted(checks)
140
140
  end
141
141
 
142
- it 'should implement the denominator procedure' do
142
+ it 'implements the denominator procedure' do
143
143
  checks = [
144
144
  ['(denominator (/ 6 4))', 2]
145
145
  ]
146
146
  compare_to_predicted(checks)
147
147
  end
148
148
 
149
- it 'should implement the floor procedure' do
149
+ it 'implements the floor procedure' do
150
150
  checks = [
151
151
  ['(floor -4.3)', -5],
152
152
  ['(floor 3.5)', 3]
@@ -154,7 +154,7 @@ SKEEM
154
154
  compare_to_predicted(checks)
155
155
  end
156
156
 
157
- it 'should implement the ceiling procedure' do
157
+ it 'implements the ceiling procedure' do
158
158
  checks = [
159
159
  ['(ceiling -4.3)', -4],
160
160
  ['(ceiling 3.5)', 4]
@@ -162,7 +162,7 @@ SKEEM
162
162
  compare_to_predicted(checks)
163
163
  end
164
164
 
165
- it 'should implement the round procedure' do
165
+ it 'implements the round procedure' do
166
166
  checks = [
167
167
  ['(round -4.3)', -4],
168
168
  ['(round 3.5)', 4],
@@ -174,7 +174,7 @@ SKEEM
174
174
  end # context
175
175
 
176
176
  context 'Comparison operators' do
177
- it 'should implement the eqv? procedure' do
177
+ it 'implements the eqv? procedure' do
178
178
  checks = [
179
179
  ['(eqv? #f #f)', true],
180
180
  ['(eqv? #t #t)', true],
@@ -202,7 +202,7 @@ SKEEM
202
202
  end
203
203
  end
204
204
 
205
- it 'should implement the equal? procedure' do
205
+ it 'implements the equal? procedure' do
206
206
  checks = [
207
207
  ['(equal? #f #f)', true],
208
208
  ['(equal? #t #t)', true],
@@ -232,7 +232,7 @@ SKEEM
232
232
  end
233
233
  end
234
234
 
235
- it 'should implement the equality operator' do
235
+ it 'implements the equality operator' do
236
236
  checks = [
237
237
  ['(= 3)', true], # '=' as unary operator
238
238
  ['(= 3 3)', true], # '=' as binary operator
@@ -244,7 +244,7 @@ SKEEM
244
244
  compare_to_predicted(checks)
245
245
  end
246
246
 
247
- it 'should implement the less than operator' do
247
+ it 'implements the less than operator' do
248
248
  checks = [
249
249
  ['(< 3)', false], # '<' as unary operator
250
250
  ['(< 3 4)', true], # '<' as binary operator
@@ -256,7 +256,7 @@ SKEEM
256
256
  compare_to_predicted(checks)
257
257
  end
258
258
 
259
- it 'should implement the greater than operator' do
259
+ it 'implements the greater than operator' do
260
260
  checks = [
261
261
  ['(> 3)', false], # '>' as unary operator
262
262
  ['(> 3 2)', true], # '>' as binary operator
@@ -268,7 +268,7 @@ SKEEM
268
268
  compare_to_predicted(checks)
269
269
  end
270
270
 
271
- it 'should implement the less or equal than operator' do
271
+ it 'implements the less or equal than operator' do
272
272
  checks = [
273
273
  ['(<= 3)', true], # '<=' as unary operator
274
274
  ['(<= 3 4)', true], # '<=' as binary operator
@@ -281,7 +281,7 @@ SKEEM
281
281
  compare_to_predicted(checks)
282
282
  end
283
283
 
284
- it 'should implement the greater or equal than operator' do
284
+ it 'implements the greater or equal than operator' do
285
285
  checks = [
286
286
  ['(>= 3)', true], # '>=' as unary operator
287
287
  ['(>= 3 2)', true],
@@ -294,7 +294,7 @@ SKEEM
294
294
  compare_to_predicted(checks)
295
295
  end
296
296
 
297
- it 'should implement the max procedure' do
297
+ it 'implements the max procedure' do
298
298
  checks = [
299
299
  ['(max 3 4)', 4],
300
300
  ['(max 3.9 4)', 4],
@@ -303,7 +303,7 @@ SKEEM
303
303
  compare_to_predicted(checks)
304
304
  end
305
305
 
306
- it 'should implement the min procedure' do
306
+ it 'implements the min procedure' do
307
307
  checks = [
308
308
  ['(min 3 4)', 3],
309
309
  ['(min 3.9 4)', 3.9],
@@ -314,7 +314,7 @@ SKEEM
314
314
  end # context
315
315
 
316
316
  context 'Number procedures:' do
317
- it 'should implement the number? predicate' do
317
+ it 'implements the number? predicate' do
318
318
  checks = [
319
319
  ['(number? 3.1)', true],
320
320
  ['(number? 22/7)', true],
@@ -325,7 +325,7 @@ SKEEM
325
325
  compare_to_predicted(checks)
326
326
  end
327
327
 
328
- it 'should implement the real? predicate' do
328
+ it 'implements the real? predicate' do
329
329
  checks = [
330
330
  ['(real? 3.1)', true],
331
331
  ['(real? 22/7)', true],
@@ -336,7 +336,7 @@ SKEEM
336
336
  compare_to_predicted(checks)
337
337
  end
338
338
 
339
- it 'should implement the rational? predicate' do
339
+ it 'implements the rational? predicate' do
340
340
  checks = [
341
341
  ['(rational? 3.1)', false],
342
342
  ['(rational? 3.0)', true],
@@ -348,7 +348,7 @@ SKEEM
348
348
  compare_to_predicted(checks)
349
349
  end
350
350
 
351
- it 'should implement the integer? predicate' do
351
+ it 'implements the integer? predicate' do
352
352
  checks = [
353
353
  ['(integer? 3.1)', false],
354
354
  ['(integer? 3.0)', true],
@@ -360,7 +360,7 @@ SKEEM
360
360
  compare_to_predicted(checks)
361
361
  end
362
362
 
363
- it 'should implement the number->string procedure' do
363
+ it 'implements the number->string procedure' do
364
364
  checks = [
365
365
  ['(number->string 3.4)', '3.4'],
366
366
  ['(number->string 22/7)', '22/7'],
@@ -373,7 +373,7 @@ SKEEM
373
373
  end # context
374
374
 
375
375
  context 'Boolean procedures:' do
376
- it 'should implement the and procedure' do
376
+ it 'implements the and procedure' do
377
377
  checks = [
378
378
  ['(and (= 2 2) (> 2 1))', true],
379
379
  ['(and (= 2 2) (< 2 1))', false],
@@ -384,14 +384,14 @@ SKEEM
384
384
  # If all the expressions evaluate to true values,
385
385
  # the values of the last expression are returned.
386
386
  source = "(and 1 2 'c '(f g))"
387
- result = subject.run(source)
388
- expect(result).to be_kind_of(SkmPair)
387
+ result = builder.run(source)
388
+ expect(result).to be_a(SkmPair)
389
389
  expect(result.car).to eq('f')
390
- expect(result.cdr).to be_kind_of(SkmPair)
390
+ expect(result.cdr).to be_a(SkmPair)
391
391
  expect(result.cdr.car).to eq('g')
392
392
  end
393
393
 
394
- it 'should implement the or procedure' do
394
+ it 'implements the or procedure' do
395
395
  checks = [
396
396
  ['(or (= 2 2) (> 2 1))', true],
397
397
  ['(or (= 2 2) (< 2 1))', true],
@@ -406,12 +406,12 @@ SKEEM
406
406
  # When an expression evaluates to true value,
407
407
  # the values of the this expression is returned.
408
408
  source = "(or #f 'a #f)"
409
- result = subject.run(source)
410
- expect(result).to be_kind_of(SkmIdentifier)
409
+ result = builder.run(source)
410
+ expect(result).to be_a(SkmIdentifier)
411
411
  expect(result).to eq('a')
412
412
  end
413
413
 
414
- it 'should implement the boolean? procedure' do
414
+ it 'implements the boolean? procedure' do
415
415
  checks = [
416
416
  ['(boolean? #f)', true],
417
417
  ['(boolean? 0)', false],
@@ -420,7 +420,7 @@ SKEEM
420
420
  compare_to_predicted(checks)
421
421
  end
422
422
 
423
- it 'should implement the boolean=? procedure' do
423
+ it 'implements the boolean=? procedure' do
424
424
  checks = [
425
425
  ['(boolean=? #t #t)', true],
426
426
  ['(boolean=? #f #f)', true],
@@ -432,7 +432,7 @@ SKEEM
432
432
  end # context
433
433
 
434
434
  context 'String procedures:' do
435
- it 'should implement the string? procedure' do
435
+ it 'implements the string? procedure' do
436
436
  checks = [
437
437
  ['(string? #f)', false],
438
438
  ['(string? 3)', false],
@@ -441,17 +441,17 @@ SKEEM
441
441
  compare_to_predicted(checks)
442
442
  end
443
443
 
444
- it 'should implement the string->symbol procedure' do
444
+ it 'implements the string->symbol procedure' do
445
445
  checks = [
446
446
  ['(string->symbol "mISSISSIppi")', 'mISSISSIppi']
447
447
  ]
448
448
  checks.each do |(skeem_expr, expectation)|
449
- result = subject.run(skeem_expr)
449
+ result = builder.run(skeem_expr)
450
450
  expect(result).to eq(expectation)
451
451
  end
452
452
  end
453
453
 
454
- it 'should implement the string=? procedure' do
454
+ it 'implements the string=? procedure' do
455
455
  checks = [
456
456
  ['(string=? "Mom" "Mom")', true],
457
457
  ['(string=? "Mom" "Mum")', false],
@@ -460,7 +460,7 @@ SKEEM
460
460
  compare_to_predicted(checks)
461
461
  end
462
462
 
463
- it 'should implement the string procedure' do
463
+ it 'implements the string procedure' do
464
464
  checks = [
465
465
  ['(string)', ''],
466
466
  ['(string #\a #\b #\c)', 'abc'],
@@ -469,7 +469,7 @@ SKEEM
469
469
  compare_to_predicted(checks)
470
470
  end
471
471
 
472
- it 'should implement the make-string procedure' do
472
+ it 'implements the make-string procedure' do
473
473
  checks = [
474
474
  ['(make-string 0)', ''],
475
475
  ['(make-string 0 #\x)', ''],
@@ -478,7 +478,7 @@ SKEEM
478
478
  compare_to_predicted(checks)
479
479
  end
480
480
 
481
- it 'should implement the string-append procedure' do
481
+ it 'implements the string-append procedure' do
482
482
  checks = [
483
483
  ['(string-append)', ''],
484
484
  ['(string-append "abc" "def")', 'abcdef'],
@@ -487,7 +487,7 @@ SKEEM
487
487
  compare_to_predicted(checks)
488
488
  end
489
489
 
490
- it 'should implement the string-length procedure' do
490
+ it 'implements the string-length procedure' do
491
491
  checks = [
492
492
  ['(string-length "abc")', 3],
493
493
  ['(string-length "")', 0],
@@ -498,7 +498,7 @@ SKEEM
498
498
  end # context
499
499
 
500
500
  context 'Symbol procedures:' do
501
- it 'should implement the symbol? procedure' do
501
+ it 'implements the symbol? procedure' do
502
502
  checks = [
503
503
  ["(symbol? 'foo)", true],
504
504
  ["(symbol? (car '(a b)))", true],
@@ -510,7 +510,7 @@ SKEEM
510
510
  compare_to_predicted(checks)
511
511
  end
512
512
 
513
- it 'should implement the symbol->string procedure' do
513
+ it 'implements the symbol->string procedure' do
514
514
  checks = [
515
515
  ["(equal? (symbol->string 'Hi) \"Hi\")", true],
516
516
  ["(equal? (symbol->string 'flying-fish) \"flying-fish\")", true],
@@ -522,7 +522,7 @@ SKEEM
522
522
  end # context
523
523
 
524
524
  context 'List procedures:' do
525
- it 'should implement the pair? procedure' do
525
+ it 'implements the pair? procedure' do
526
526
  checks = [
527
527
  ["(pair? '(a . b))", true],
528
528
  ["(pair? '(a b c))", true],
@@ -532,7 +532,7 @@ SKEEM
532
532
  compare_to_predicted(checks)
533
533
  end
534
534
 
535
- it 'should implement the list? procedure' do
535
+ it 'implements the list? procedure' do
536
536
  checks = [
537
537
  ['(list? #f)', false],
538
538
  ['(list? 1)', false],
@@ -546,7 +546,7 @@ SKEEM
546
546
  compare_to_predicted(checks)
547
547
  end
548
548
 
549
- it 'should implement the null? procedure' do
549
+ it 'implements the null? procedure' do
550
550
  checks = [
551
551
  ['(null? #f)', false],
552
552
  ['(null? 1)', false],
@@ -559,14 +559,14 @@ SKEEM
559
559
  compare_to_predicted(checks)
560
560
  end
561
561
 
562
- it 'should implement the cons procedure' do
562
+ it 'implements the cons procedure' do
563
563
  example = "(cons 'a '())" # => (a)
564
- result = subject.run(example)
564
+ result = builder.run(example)
565
565
  expect(result).to be_list
566
566
  expect(result.car).to eq('a')
567
567
 
568
568
  example = "(cons '(a) '(b c d))" # => ((a) b c d)
569
- result = subject.run(example)
569
+ result = builder.run(example)
570
570
  expect(result).to be_list
571
571
  members = result.to_a
572
572
  expect(members[0]).to be_list
@@ -576,33 +576,33 @@ SKEEM
576
576
  expect(members[3]).to eq('d')
577
577
 
578
578
  example = "(cons \"a\" '(b c))" # => ("a" b c)
579
- result = subject.run(example)
579
+ result = builder.run(example)
580
580
  expect(result).to be_list
581
- expect(result.car).to be_kind_of(SkmString)
581
+ expect(result.car).to be_a(SkmString)
582
582
  expect(result.car).to eq('a')
583
- expect(result.cdr.car).to be_kind_of(SkmIdentifier)
583
+ expect(result.cdr.car).to be_a(SkmIdentifier)
584
584
  expect(result.cdr.car).to eq('b')
585
- expect(result.cdr.cdr.car).to be_kind_of(SkmIdentifier)
585
+ expect(result.cdr.cdr.car).to be_a(SkmIdentifier)
586
586
  expect(result.cdr.cdr.car).to eq('c')
587
587
 
588
588
  example = "(cons 'a 3)" # => (a . 3)
589
- result = subject.run(example)
589
+ result = builder.run(example)
590
590
  expect(result.car).to eq('a')
591
591
  expect(result.cdr).to eq(3)
592
592
 
593
593
  example = "(cons '(a b) 'c)" # => ((a b) . c)
594
- result = subject.run(example)
595
- expect(result.car).to be_kind_of(SkmPair)
594
+ result = builder.run(example)
595
+ expect(result.car).to be_a(SkmPair)
596
596
  expect(result.car.to_a).to eq(%w[a b])
597
- expect(result.cdr).to be_kind_of(SkmIdentifier)
597
+ expect(result.cdr).to be_a(SkmIdentifier)
598
598
  expect(result.cdr).to eq('c')
599
599
  end
600
600
 
601
- it 'should implement the car procedure' do
601
+ it 'implements the car procedure' do
602
602
  expect_expr("(car '(a b c))").to eq('a')
603
603
 
604
604
  example = "(car '((a) b c d))" # => (a)
605
- result = subject.run(example)
605
+ result = builder.run(example)
606
606
  expect(result).to be_list
607
607
  expect(result.length).to eq(1)
608
608
  expect(result.car).to eq('a')
@@ -610,12 +610,12 @@ SKEEM
610
610
  expect_expr("(car '(1 . 2))").to eq(1)
611
611
 
612
612
  example = "(car '())" # => error
613
- expect { subject.run(example) }.to raise_error(StandardError)
613
+ expect { builder.run(example) }.to raise_error(StandardError)
614
614
  end
615
615
 
616
- it 'should implement the cdr procedure' do
616
+ it 'implements the cdr procedure' do
617
617
  example = "(cdr '((a) b c d))" # => (b c d)
618
- result = subject.run(example)
618
+ result = builder.run(example)
619
619
  expect(result).to be_list
620
620
  expect(result.length).to eq(3)
621
621
  expect(result.to_a).to eq(%w[b c d])
@@ -623,18 +623,18 @@ SKEEM
623
623
  expect_expr("(cdr '(1 . 2))").to eq(2)
624
624
 
625
625
  example = "(cdr '())" # => error
626
- expect { subject.run(example) }.to raise_error(StandardError)
626
+ expect { builder.run(example) }.to raise_error(StandardError)
627
627
  end
628
628
 
629
- it 'should implement the length procedure' do
629
+ it 'implements the length procedure' do
630
630
  example = '(make-list 2 3)'
631
- result = subject.run(example)
631
+ result = builder.run(example)
632
632
  expect(result).to be_list
633
633
  expect(result.length).to eq(2)
634
634
  expect(result.to_a).to eq([3, 3])
635
635
  end
636
636
 
637
- it 'should implement the length procedure' do
637
+ it 'implements the length procedure' do
638
638
  checks = [
639
639
  ["(length '())", 0],
640
640
  ["(length '(1))", 1],
@@ -645,7 +645,7 @@ SKEEM
645
645
  compare_to_predicted(checks)
646
646
  end
647
647
 
648
- it 'should implement the append procedure' do
648
+ it 'implements the append procedure' do
649
649
  checks = [
650
650
  ["(append '(a b c) '())", array2list_ids(%w[a b c])],
651
651
  ["(append '() '(a b c))", array2list_ids(%w[a b c])],
@@ -667,8 +667,8 @@ SKEEM
667
667
  end
668
668
  end
669
669
 
670
- it 'should implement the procedure for an improper list' do
671
- result = subject.run("(append '(a b) '(c . d))")
670
+ it 'implements the procedure for an improper list' do
671
+ result = builder.run("(append '(a b) '(c . d))")
672
672
  expect(result.car).to eq(SkmIdentifier.create('a'))
673
673
  expect(result.cdr.car).to eq(SkmIdentifier.create('b'))
674
674
  expect(result.cdr.cdr.car).to eq(SkmIdentifier.create('c'))
@@ -676,7 +676,7 @@ SKEEM
676
676
  end
677
677
 
678
678
 
679
- it 'should implement the reverse procedure' do
679
+ it 'implements the reverse procedure' do
680
680
  checks = [
681
681
  ["(reverse '())", SkmEmptyList.instance],
682
682
  ["(reverse '(a b c))", array2list_ids(%w[c b a])],
@@ -691,7 +691,7 @@ SKEEM
691
691
  end
692
692
  end
693
693
 
694
- it 'should implement the list->vector procedure' do
694
+ it 'implements the list->vector procedure' do
695
695
  checks = [
696
696
  ["(list->vector '())", []],
697
697
  ["(list->vector '(a b c))", %w[a b c]]
@@ -701,28 +701,28 @@ SKEEM
701
701
  end
702
702
  end
703
703
 
704
- it 'should implement the set-car! procedure' do
704
+ it 'implements the set-car! procedure' do
705
705
  source = <<-SKEEM
706
706
  (define x '(a b c))
707
707
  (set-car! x 1)
708
708
  x
709
709
  SKEEM
710
- result = subject.run(source)
710
+ result = builder.run(source)
711
711
  expect(result.last.car).to eq(1)
712
712
  end
713
713
 
714
- it 'should implement the set-cdr! procedure' do
714
+ it 'implements the set-cdr! procedure' do
715
715
  source = <<-SKEEM
716
716
  (define x '(a b c))
717
717
  (set-cdr! x 1)
718
718
  x
719
719
  SKEEM
720
- result = subject.run(source)
720
+ result = builder.run(source)
721
721
  expect(result.last.cdr).to eq(1)
722
722
  end
723
723
 
724
- it 'should implement the assq procedure' do
725
- subject.run("(define e '((a 1) (b 2) (c 3)))")
724
+ it 'implements the assq procedure' do
725
+ builder.run("(define e '((a 1) (b 2) (c 3)))")
726
726
  checks = [
727
727
  ["(assq 'a e)", ['a', 1]],
728
728
  ["(assq 'b e)", ['b', 2]],
@@ -738,12 +738,12 @@ SKEEM
738
738
  expect_expr("(assq '(a) '(((a)) ((b)) ((c))))").to eq(false)
739
739
  end
740
740
 
741
- it 'should implement the assv procedure' do
742
- result = subject.run("(assv 5 '((2 3) (5 7) (11 13)))")
741
+ it 'implements the assv procedure' do
742
+ result = builder.run("(assv 5 '((2 3) (5 7) (11 13)))")
743
743
  expect(result.to_a).to eq([5, 7])
744
744
  end
745
745
 
746
- it 'should implement the list-copy procedure' do
746
+ it 'implements the list-copy procedure' do
747
747
  checks = [
748
748
  ["(list-copy '())", []],
749
749
  ["(list-copy '(a b c))", %w[a b c]]
@@ -757,16 +757,16 @@ SKEEM
757
757
  (define b (list-copy a))
758
758
  (set-car! b 3) ; b is mutable
759
759
  SKEEM
760
- subject.run(source)
761
- result = subject.run('b')
760
+ builder.run(source)
761
+ result = builder.run('b')
762
762
  expect(result.to_a).to eq([3, 8, 2, 8])
763
- result = subject.run('a')
763
+ result = builder.run('a')
764
764
  expect(result.to_a).to eq([1, 8, 2, 8])
765
765
  end
766
766
  end # context
767
767
 
768
768
  context 'Character procedures:' do
769
- it 'should implement the char? procedure' do
769
+ it 'implements the char? procedure' do
770
770
  checks = [
771
771
  ['(char? #f)', false],
772
772
  ["(char? 'a)", false],
@@ -777,7 +777,7 @@ SKEEM
777
777
  compare_to_predicted(checks)
778
778
  end
779
779
 
780
- it 'should implement the char->integer procedure' do
780
+ it 'implements the char->integer procedure' do
781
781
  checks = [
782
782
  ['(char->integer #\space)', 0x20],
783
783
  ['(char->integer #\newline)', 0x0a],
@@ -787,7 +787,7 @@ SKEEM
787
787
  compare_to_predicted(checks)
788
788
  end
789
789
 
790
- it 'should implement the integer->char procedure' do
790
+ it 'implements the integer->char procedure' do
791
791
  checks = [
792
792
  ['(integer->char #x20)', ?\s],
793
793
  ['(integer->char 48)', ?0],
@@ -797,7 +797,7 @@ SKEEM
797
797
  compare_to_predicted(checks)
798
798
  end
799
799
 
800
- it 'should implement the char=? procedure' do
800
+ it 'implements the char=? procedure' do
801
801
  checks = [
802
802
  ['(char=? #\a)', true],
803
803
  ['(char=? #\a #\a)', true],
@@ -808,7 +808,7 @@ SKEEM
808
808
  compare_to_predicted(checks)
809
809
  end
810
810
 
811
- it 'should implement the char<? procedure' do
811
+ it 'implements the char<? procedure' do
812
812
  checks = [
813
813
  ['(char<? #\a)', true],
814
814
  ['(char<? #\a #\a)', false],
@@ -819,7 +819,7 @@ SKEEM
819
819
  compare_to_predicted(checks)
820
820
  end
821
821
 
822
- it 'should implement the char>? procedure' do
822
+ it 'implements the char>? procedure' do
823
823
  checks = [
824
824
  ['(char>? #\b)', true],
825
825
  ['(char>? #\b #\b)', false],
@@ -830,7 +830,7 @@ SKEEM
830
830
  compare_to_predicted(checks)
831
831
  end
832
832
 
833
- it 'should implement the char<=? procedure' do
833
+ it 'implements the char<=? procedure' do
834
834
  checks = [
835
835
  ['(char<=? #\a)', true],
836
836
  ['(char<=? #\a #\a)', true],
@@ -842,7 +842,7 @@ SKEEM
842
842
  compare_to_predicted(checks)
843
843
  end
844
844
 
845
- it 'should implement the char>=? procedure' do
845
+ it 'implements the char>=? procedure' do
846
846
  checks = [
847
847
  ['(char>=? #\a)', true],
848
848
  ['(char>=? #\a #\a)', true],
@@ -856,7 +856,7 @@ SKEEM
856
856
  end # context
857
857
 
858
858
  context 'Vector procedures:' do
859
- it 'should implement the vector? procedure' do
859
+ it 'implements the vector? procedure' do
860
860
  checks = [
861
861
  ['(vector? #f)', false],
862
862
  ['(vector? 1)', false],
@@ -867,19 +867,19 @@ SKEEM
867
867
  compare_to_predicted(checks)
868
868
  end
869
869
 
870
- it 'should implement the vector procedure' do
870
+ it 'implements the vector procedure' do
871
871
  source = '(vector)'
872
- result = subject.run(source)
873
- expect(result).to be_kind_of(SkmVector)
872
+ result = builder.run(source)
873
+ expect(result).to be_a(SkmVector)
874
874
  expect(result).to be_empty
875
875
 
876
876
  source = '(vector 1 2 3)'
877
- result = subject.run(source)
878
- expect(result).to be_kind_of(SkmVector)
877
+ result = builder.run(source)
878
+ expect(result).to be_a(SkmVector)
879
879
  expect(result.members).to eq([1, 2, 3])
880
880
  end
881
881
 
882
- it 'should implement the vector-length procedure' do
882
+ it 'implements the vector-length procedure' do
883
883
  checks = [
884
884
  ['(vector-length (vector))', 0],
885
885
  ['(vector-length #())', 0],
@@ -892,7 +892,7 @@ SKEEM
892
892
  compare_to_predicted(checks)
893
893
  end
894
894
 
895
- it 'should implement the make-vector procedure' do
895
+ it 'implements the make-vector procedure' do
896
896
  checks = [
897
897
  ['(vector-length (make-vector 0))', 0],
898
898
  ["(vector-length (make-vector 0 'a))", 0],
@@ -901,14 +901,14 @@ SKEEM
901
901
  compare_to_predicted(checks)
902
902
  end
903
903
 
904
- it 'should implement the vector-ref procedure' do
904
+ it 'implements the vector-ref procedure' do
905
905
  source = "(vector-ref '#(1 1 2 3 5 8 13 21) 5)"
906
- result = subject.run(source)
907
- expect(result).to be_kind_of(SkmInteger)
906
+ result = builder.run(source)
907
+ expect(result).to be_a(SkmInteger)
908
908
  expect(result).to eq(8)
909
909
  end
910
910
 
911
- it 'should implement the vector-set! procedure' do
911
+ it 'implements the vector-set! procedure' do
912
912
  source = <<-SKEEM
913
913
  (let
914
914
  ((vec (vector 0 '(2 2 2 2) "Anna")))
@@ -916,8 +916,8 @@ SKEEM
916
916
  vec)
917
917
  SKEEM
918
918
  # (0 ("Sue" "Sue") "Anna")
919
- result = subject.run(source)
920
- expect(result).to be_kind_of(SkmVector)
919
+ result = builder.run(source)
920
+ expect(result).to be_a(SkmVector)
921
921
  expectation = [SkmInteger.create(0),
922
922
  SkmPair.new(SkmString.create('Sue'), SkmPair.new(SkmString.create('Sue'), SkmEmptyList.instance)),
923
923
  SkmString.create('Anna')]
@@ -929,12 +929,12 @@ SKEEM
929
929
  (vector-set! v 2 'x)
930
930
  v)
931
931
  SKEEM
932
- result = subject.run(source)
933
- expect(result).to be_kind_of(SkmVector)
932
+ result = builder.run(source)
933
+ expect(result).to be_a(SkmVector)
934
934
  expect(result).to eq(array2list_ids(%w[a b x d e]))
935
935
  end
936
936
 
937
- it 'should implement the vector->list procedure' do
937
+ it 'implements the vector->list procedure' do
938
938
  checks = [
939
939
  ['(vector->list #())', []],
940
940
  ["(vector->list '#(a b c))", %w[a b c]]
@@ -946,7 +946,7 @@ SKEEM
946
946
  end # context
947
947
 
948
948
  context 'Control procedures:' do
949
- it 'should implement the procedure? predicate' do
949
+ it 'implements the procedure? predicate' do
950
950
  checks = [
951
951
  ['(procedure? car)', true],
952
952
  ["(procedure? 'car)", false],
@@ -956,14 +956,14 @@ SKEEM
956
956
  compare_to_predicted(checks)
957
957
  end
958
958
 
959
- it 'should implement the apply procedure' do
959
+ it 'implements the apply procedure' do
960
960
  checks = [
961
961
  ["(apply + '(3 4))", 7]
962
962
  ]
963
963
  compare_to_predicted(checks)
964
964
  end
965
965
 
966
- it 'should implement the map procedure' do
966
+ it 'implements the map procedure' do
967
967
  checks = [
968
968
  ["(map car '((a b) (d e) (g h)))", %w[a d g]],
969
969
  ["(map + '(1 2 3) '(4 5 6 7))", [5, 7, 9]]
@@ -975,33 +975,29 @@ SKEEM
975
975
  end # context
976
976
 
977
977
  context 'IO procedures:' do
978
- it 'should implement the display procedure' do
979
- default_stdout = $stdout
980
- $stdout = StringIO.new
981
- subject.run('(display "Hello")')
982
- expect($stdout.string).to eq('Hello')
983
- $stdout = default_stdout
978
+ it 'implements the display procedure' do
979
+ expect { builder.run('(display "Hello")') }.to output('Hello').to_stdout
984
980
  end
985
981
  end # context
986
982
 
987
983
  context 'Miscellaneous procedures' do
988
- it 'should raise an exception with given error message' do
984
+ it 'raises an exception with given error message' do
989
985
  source = '(error "This is an error message")'
990
986
  err = SkmError
991
987
  msg = 'This is an error message'
992
- expect { subject.run(source) }.to raise_error(err, msg)
988
+ expect { builder.run(source) }.to raise_error(err, msg)
993
989
  end
994
990
 
995
- it 'should return true when an assertion succeeds' do
991
+ it 'returns true when an assertion succeeds' do
996
992
  source = <<-SKEEM
997
993
  (define x 2)
998
994
  (define y 1)
999
995
  (test-assert (> x y))
1000
996
  SKEEM
1001
- expect(subject.run(source).last).to eq(true)
997
+ expect(builder.run(source).last).to eq(true)
1002
998
  end
1003
999
 
1004
- it 'should raise an error when an assertion fails' do
1000
+ it 'raises an error when an assertion fails' do
1005
1001
  source = <<-SKEEM
1006
1002
  (define x 1)
1007
1003
  (define y 2)
@@ -1010,7 +1006,7 @@ SKEEM
1010
1006
  err = StandardError
1011
1007
  msg1 = 'Error: assertion failed on line 3, column 4'
1012
1008
  msg2 = 'with <Skeem::SkmBoolean: false>'
1013
- expect { subject.run(source) }.to raise_error(err, "#{msg1}, #{msg2}")
1009
+ expect { builder.run(source) }.to raise_error(err, "#{msg1}, #{msg2}")
1014
1010
  end
1015
1011
  end # context
1016
1012
  end # describe