loxxy 0.0.9 → 0.0.14

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.
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'spec_helper' # Use the RSpec framework
4
+ require 'stringio'
5
+
6
+ # Load the class under test
7
+ require_relative '../lib/loxxy/interpreter'
8
+
9
+ module Loxxy
10
+ # This spec contains the bare bones test for the Interpreter class.
11
+ # The execution of Lox code is tested elsewhere.
12
+ describe Interpreter do
13
+ let(:sample_cfg) do
14
+ { ostream: StringIO.new }
15
+ end
16
+ subject { Interpreter.new(sample_cfg) }
17
+
18
+ context 'Initialization:' do
19
+ it 'should accept a option Hash at initialization' do
20
+ expect { Interpreter.new(sample_cfg) }.not_to raise_error
21
+ end
22
+
23
+ it 'should know its config options' do
24
+ expect(subject.config).to eq(sample_cfg)
25
+ end
26
+ end # context
27
+
28
+ context 'Evaluating Lox code:' do
29
+ let(:hello_world) { 'print "Hello, world!";' }
30
+
31
+ it 'should evaluate core data types' do
32
+ result = subject.evaluate('true; // Not false')
33
+ expect(result).to be_kind_of(Loxxy::Datatype::True)
34
+ end
35
+
36
+ it 'should evaluate arithmetic operation' do
37
+ result = subject.evaluate('123 + 456; // => 579')
38
+ expect(result).to be_kind_of(Loxxy::Datatype::Number)
39
+ expect(result == 579).to be_true
40
+ end
41
+
42
+ it 'should evaluate string concatenation' do
43
+ result = subject.evaluate('"str" + "ing"; // => "string"')
44
+ expect(result).to be_kind_of(Loxxy::Datatype::LXString)
45
+ expect(result == 'string').to be_true
46
+ end
47
+
48
+ it 'should print the hello world message' do
49
+ expect { subject.evaluate(hello_world) }.not_to raise_error
50
+ expect(sample_cfg[:ostream].string).to eq('Hello, world!')
51
+ end
52
+ end # context
53
+ end # describe
54
+ end # module
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loxxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitri Geshef
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-07 00:00:00.000000000 Z
11
+ date: 2021-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rley
@@ -84,12 +84,16 @@ files:
84
84
  - README.md
85
85
  - Rakefile
86
86
  - lib/loxxy.rb
87
+ - lib/loxxy/ast/all_lox_nodes.rb
87
88
  - lib/loxxy/ast/ast_builder.rb
88
89
  - lib/loxxy/ast/ast_visitor.rb
89
90
  - lib/loxxy/ast/lox_binary_expr.rb
90
91
  - lib/loxxy/ast/lox_compound_expr.rb
91
92
  - lib/loxxy/ast/lox_literal_expr.rb
92
93
  - lib/loxxy/ast/lox_node.rb
94
+ - lib/loxxy/ast/lox_noop_expr.rb
95
+ - lib/loxxy/ast/lox_print_stmt.rb
96
+ - lib/loxxy/back_end/engine.rb
93
97
  - lib/loxxy/datatype/all_datatypes.rb
94
98
  - lib/loxxy/datatype/boolean.rb
95
99
  - lib/loxxy/datatype/builtin_datatype.rb
@@ -103,12 +107,18 @@ files:
103
107
  - lib/loxxy/front_end/parser.rb
104
108
  - lib/loxxy/front_end/raw_parser.rb
105
109
  - lib/loxxy/front_end/scanner.rb
110
+ - lib/loxxy/interpreter.rb
106
111
  - lib/loxxy/version.rb
107
112
  - loxxy.gemspec
113
+ - spec/back_end/engine_spec.rb
114
+ - spec/datatype/boolean_spec.rb
108
115
  - spec/datatype/lx_string_spec.rb
116
+ - spec/datatype/nil_spec.rb
117
+ - spec/datatype/number_spec.rb
109
118
  - spec/front_end/parser_spec.rb
110
119
  - spec/front_end/raw_parser_spec.rb
111
120
  - spec/front_end/scanner_spec.rb
121
+ - spec/interpreter_spec.rb
112
122
  - spec/loxxy_spec.rb
113
123
  - spec/spec_helper.rb
114
124
  homepage: https://github.com/famished-tiger/loxxy
@@ -136,8 +146,13 @@ signing_key:
136
146
  specification_version: 4
137
147
  summary: An implementation of the Lox programming language. WIP
138
148
  test_files:
149
+ - spec/back_end/engine_spec.rb
150
+ - spec/datatype/boolean_spec.rb
139
151
  - spec/datatype/lx_string_spec.rb
152
+ - spec/datatype/nil_spec.rb
153
+ - spec/datatype/number_spec.rb
140
154
  - spec/front_end/parser_spec.rb
141
155
  - spec/front_end/raw_parser_spec.rb
142
156
  - spec/front_end/scanner_spec.rb
157
+ - spec/interpreter_spec.rb
143
158
  - spec/loxxy_spec.rb