mips_tester 0.1.1 → 0.1.2

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.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mips_tester (0.1.0)
4
+ mips_tester (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/lib/mips_tester.rb CHANGED
@@ -3,7 +3,7 @@ require 'tempfile' unless defined? Tempfile
3
3
  # Main MIPSTester module
4
4
  module MIPSTester
5
5
  # Library version
6
- VERSION = "0.1.1"
6
+ VERSION = "0.1.2"
7
7
 
8
8
  # MIPSFileError Exception, raised when test file is not valid or non-existent
9
9
  class MIPSFileError < Exception; end
@@ -64,7 +64,8 @@ module MIPSTester
64
64
  instance_eval(&block)
65
65
 
66
66
  asm = Tempfile.new "temp.asm"
67
- asm.write(prep_params + File.read(file))
67
+ asm.write prep_params if block
68
+ asm.write File.read(file)
68
69
  asm.close
69
70
 
70
71
  cli = `#{["java -jar",
@@ -81,8 +82,7 @@ module MIPSTester
81
82
 
82
83
  return compare_hashes(@exp, results)
83
84
  rescue Exception => ex
84
- puts ex.message
85
- return false
85
+ raise MIPSFileError.new ex.message.gsub(asm.path, File.basename(file)).split("\n")[0..1].join("\n")
86
86
  ensure
87
87
  asm.unlink
88
88
  end
@@ -0,0 +1 @@
1
+ add t0, t1, t2
data/spec/mips_spec.rb CHANGED
@@ -14,18 +14,25 @@ describe MIPS do
14
14
  end
15
15
 
16
16
  it 'should raise exception if not valid file path is given' do
17
- mips = MIPS.new :mars_path => "/Applications/MARS_4_1.jar"
18
17
  expect do
19
- mips.test fixture_path("non-existing.asm") {}
18
+ mips.test fixture_path("non-existing.asm")
20
19
  end.to raise_error(::MIPSFileError)
21
20
  end
22
21
 
23
22
  it 'should raise exception if no block is given on test method' do
24
- mips = MIPS.new :mars_path => "/Applications/MARS_4_1.jar"
25
23
  expect do
26
24
  mips.test fixture_path("empty.asm")
27
25
  end.to raise_error(::MIPSInvalidBlockError)
28
26
  end
27
+
28
+ it 'should raise exception if file given isn\'t parsable by MARS' do
29
+ expect do
30
+ mips.test fixture_path("invalid_syntax.asm") do
31
+ set t1: 0, t2: 3
32
+ expect t1: 0, t2: 3
33
+ end
34
+ end.to raise_error(::MIPSFileError)
35
+ end
29
36
  end
30
37
 
31
38
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: mips_tester
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.1
5
+ version: 0.1.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Federico Ravasio
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-04 00:00:00 Z
13
+ date: 2011-05-17 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -43,6 +43,7 @@ files:
43
43
  - mips_tester.gemspec
44
44
  - spec/fixtures/add.asm
45
45
  - spec/fixtures/empty.asm
46
+ - spec/fixtures/invalid_syntax.asm
46
47
  - spec/mips_spec.rb
47
48
  - spec/spec_helper.rb
48
49
  homepage: http://github.com/razielgn/mips_tester
@@ -75,6 +76,7 @@ summary: Class to test MIPS asm files
75
76
  test_files:
76
77
  - spec/fixtures/add.asm
77
78
  - spec/fixtures/empty.asm
79
+ - spec/fixtures/invalid_syntax.asm
78
80
  - spec/mips_spec.rb
79
81
  - spec/spec_helper.rb
80
82
  has_rdoc: