Browse Source

Run prettier

master
Dylan Baker 5 years ago
parent
commit
dfc72ec77b
5 changed files with 21 additions and 36 deletions
  1. 1
    2
      lib/chervil.rb
  2. 3
    3
      spec/env_spec.rb
  3. 1
    1
      spec/interpreter_spec.rb
  4. 1
    1
      spec/lexer_spec.rb
  5. 15
    29
      spec/parser_spec.rb

+ 1
- 2
lib/chervil.rb View File

@@ -8,5 +8,4 @@ require 'chervil/parser'
8 8
 require 'chervil/token'
9 9
 require 'chervil/version'
10 10
 
11
-module Chervil
12
-end
11
+module Chervil; end

+ 3
- 3
spec/env_spec.rb View File

@@ -2,14 +2,14 @@ module Chervil
2 2
   RSpec.describe Env do
3 3
     it 'has arithmetic from core' do
4 4
       env = Env.new
5
-      expect(env.get("+").call([1, 2], env)).to eq(3)
5
+      expect(env.get('+').call([1, 2], env)).to eq(3)
6 6
     end
7 7
 
8 8
     it 'inherits from parent env' do
9 9
       parent = Env.new
10
-      parent.set("x", 5)
10
+      parent.set('x', 5)
11 11
       child = Env.new(parent)
12
-      expect(child.get("x")).to eq(5)
12
+      expect(child.get('x')).to eq(5)
13 13
     end
14 14
   end
15 15
 end

+ 1
- 1
spec/interpreter_spec.rb View File

@@ -9,7 +9,7 @@ module Chervil
9 9
     it 'interprets a definition and variable usage' do
10 10
       env = Env.new
11 11
       interpret('(define x 5)', env)
12
-      expect(env.get("x")).to eq(AST::Number.new(5.0))
12
+      expect(env.get('x')).to eq(AST::Number.new(5.0))
13 13
       expect(interpret('x', env).first).to eq(5.0)
14 14
     end
15 15
 

+ 1
- 1
spec/lexer_spec.rb View File

@@ -45,7 +45,7 @@ module Chervil
45 45
     end
46 46
 
47 47
     it 'lexes booleans' do
48
-      lexer = Lexer.new("#t #f")
48
+      lexer = Lexer.new('#t #f')
49 49
       expect(lexer.get_next_token).to eq(Token.new(:boolean, true))
50 50
       expect(lexer.get_next_token).to eq(Token.new(:boolean, false))
51 51
     end

+ 15
- 29
spec/parser_spec.rb View File

@@ -20,10 +20,7 @@ module Chervil
20 20
 
21 21
     it 'parses booleans' do
22 22
       expect(parse('#t #f')).to eq(
23
-        [
24
-          AST::Boolean.new(true),
25
-          AST::Boolean.new(false),
26
-        ]
23
+        [AST::Boolean.new(true), AST::Boolean.new(false)]
27 24
       )
28 25
     end
29 26
 
@@ -45,22 +42,16 @@ module Chervil
45 42
     it 'parses a nested expression' do
46 43
       expect(parse('(+ (+ 1 2) (- 3 4))').first).to eq(
47 44
         AST::Application.new(
48
-          AST::Identifier.new("+"),
45
+          AST::Identifier.new('+'),
49 46
           [
50 47
             AST::Application.new(
51
-              AST::Identifier.new("+"),
52
-              [
53
-                AST::Number.new(1.0),
54
-                AST::Number.new(2.0),
55
-              ]
48
+              AST::Identifier.new('+'),
49
+              [AST::Number.new(1.0), AST::Number.new(2.0)]
56 50
             ),
57 51
             AST::Application.new(
58
-              AST::Identifier.new("-"),
59
-              [
60
-                AST::Number.new(3.0),
61
-                AST::Number.new(4.0),
62
-              ]
63
-            ),
52
+              AST::Identifier.new('-'),
53
+              [AST::Number.new(3.0), AST::Number.new(4.0)]
54
+            )
64 55
           ]
65 56
         )
66 57
       )
@@ -69,19 +60,14 @@ module Chervil
69 60
     it 'parses a function definition' do
70 61
       expect(parse('(define (square x) (* x x))').first).to eq(
71 62
         AST::Definition.new(
72
-          AST::Identifier.new("square"),
63
+          AST::Identifier.new('square'),
73 64
           AST::Function.new(
74
-            AST::Identifier.new("square"),
75
-            [
76
-              AST::Identifier.new("x")
77
-            ],
65
+            AST::Identifier.new('square'),
66
+            [AST::Identifier.new('x')],
78 67
             [
79 68
               AST::Application.new(
80
-                AST::Identifier.new("*"),
81
-                [
82
-                  AST::Identifier.new("x"),
83
-                  AST::Identifier.new("x"),
84
-                ]
69
+                AST::Identifier.new('*'),
70
+                [AST::Identifier.new('x'), AST::Identifier.new('x')]
85 71
               )
86 72
             ]
87 73
           )
@@ -90,8 +76,8 @@ module Chervil
90 76
     end
91 77
 
92 78
     it 'returns a syntax error object instead of raising' do
93
-      expect(parse('(+ 1')).to eq(Error.new("Expected rparen but got eof"))
94
-      expect(parse('1)')).to eq(Error.new("Unexpected token rparen: )"))
79
+      expect(parse('(+ 1')).to eq(Error.new('Expected rparen but got eof'))
80
+      expect(parse('1)')).to eq(Error.new('Unexpected token rparen: )'))
95 81
     end
96 82
 
97 83
     it 'parses a conditional' do
@@ -99,7 +85,7 @@ module Chervil
99 85
         AST::Conditional.new(
100 86
           AST::Boolean.new(true),
101 87
           AST::Number.new(1.0),
102
-          AST::Number.new(0.0),
88
+          AST::Number.new(0.0)
103 89
         )
104 90
       )
105 91
     end

Loading…
Cancel
Save