speckle 0.1.13 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGY0ZTgyOTljZjAxYzIxYmNlZjgxMzI2YjFkZjI1MDJjYWUwMTQxZg==
4
+ NmEwMDlhYjVmMzYyMmI3NThhNGU3NzRiYjA5ZDM3ZmE2NDU5ZTIwYQ==
5
5
  data.tar.gz: !binary |-
6
- NjNmMDBjMWQwMGIyNzgyNzVmZDE2NzRkN2JlYjFhNmMyZWMzNmM0YQ==
6
+ NjQ4OTFjNDU1MGI3OWU0N2I1NGI4ODc3NDBmZmZkMTYyYmM3OGNiNA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MmY5MTYyZjFiYjFiMTExMWY0MzFmMWJkYzhjMTIxOGRlMTU3MWJlNmNlMzYx
10
- ZDZjZTllNWJiMWI1ODk1MmY1MGNkYjRiY2NiZWYxNTA0NzczZTFkMDcyNGQw
11
- NzQ5MzYzNDdlZTM2NGY3NjM0NjU3MTI2MmNmOGZjY2M5MzdmN2E=
9
+ ZjU3NWJjZjE3NmY5MWMzNGYwYTJjNGEzOTU0ZDgzNWM3OGZiZjEzYjY3MGU0
10
+ MjBmYjFmMTgyOWM1YjQxNTIzNDM5ZTE0MjU0N2I2ZWEwMjUwYTdhNjk4MzQz
11
+ ZGY1MDY1ZGJlOTJiMTNjMWQ5M2FkOTlkZTBkNDA2ZjM3MmNkNTU=
12
12
  data.tar.gz: !binary |-
13
- ZjljYjNjYTc4NDU2NWUwZDkzMGI3NWFmMTg0YTA0YWNlMTcyZDRlMTYwZmEy
14
- YTA2MGJhNjM2ZTBlNzI2OGZhNTZiYTczNTQxYzU0NGZmMzIyZTZkMzFlMjcw
15
- NTY2MWY2MzUyOTFiMjU5MTBlNTFmMzUxOTZlZjFjYWFkYzFiODE=
13
+ NTMzYzdkNmJhZjNjNjdjN2I0NmZlMWVkNjY3NGU3MzgxNmYxMTkwNzg3MjFk
14
+ YWM0ZDk5NmEzNjBkMjg0MmEwNWZkOGI1MWIzMTkyODg1MWI4ODA5YTI3YTFi
15
+ YTg0ZDI0N2FkODlkZmRiNzk0ZWJhMmVjMGIyMzVkZmVlYTk0NzQ=
@@ -1,13 +1,76 @@
1
1
  class EqualityMatcher
2
+ def initialize
3
+ types = []
4
+ add(types, 'Number')
5
+ add(types, 'String')
6
+ add(types, 'Funcref')
7
+ add(types, 'List')
8
+ add(types, 'Dictionary')
9
+ add(types, 'Float')
10
+
11
+ self.types = types
12
+ end
13
+
2
14
  defm match(expected, actual)
3
- return actual == expected
15
+ self.type_mismatch = false
16
+
17
+ type_expected = type(expected)
18
+ type_actual = type(actual)
19
+
20
+ if type_expected != type_actual
21
+ self.type_mismatch = true
22
+ return false
23
+ end
24
+
25
+ return expected == actual
4
26
  end
5
27
 
6
28
  defm failure_message_for_match(expected, actual)
7
- return "expected “#{actual}” to equal “#{expected}”"
29
+ if self.type_mismatch
30
+ return self.type_mismatch_message(expected, actual)
31
+ end
32
+
33
+ expected_str = self.stringify(expected)
34
+ actual_str = self.stringify(actual)
35
+
36
+ return "expected “#{actual_str}” to equal “#{expected_str}”"
8
37
  end
9
38
 
10
39
  defm failure_message_for_mismatch(expected, actual)
11
- return "expected “#{actual}” to not equal “#{expected}”"
40
+ if self.type_mismatch
41
+ return self.type_mismatch_message(expected, actual)
42
+ end
43
+
44
+ expected_str = self.stringify(expected)
45
+ actual_str = self.stringify(actual)
46
+
47
+ return "expected “#{actual_str}” to not equal “#{expected_str}”"
12
48
  end
49
+
50
+ defm type_mismatch_message(expected, actual)
51
+ actual_type = self.typeof(actual)
52
+ expected_type = self.typeof(expected)
53
+
54
+ return "type mismatch, actual(#{string(actual)}) is “#{actual_type}”, expected(#{string(expected)}) is “#{expected_type}”"
55
+ end
56
+
57
+ " helpers "
58
+ defm typeof(variable)
59
+ return self.type_to_str(type(variable))
60
+ end
61
+
62
+ defm type_to_str(num)
63
+ return self.types[num]
64
+ end
65
+
66
+ defm stringify(value)
67
+ value_type = type(value)
68
+
69
+ if value_type == type('') || value_type == type(1)
70
+ return value
71
+ else
72
+ return string(value)
73
+ end
74
+ end
75
+
13
76
  end
@@ -1,3 +1,3 @@
1
1
  module Speckle
2
- VERSION = "0.1.13"
2
+ VERSION = "0.1.14"
3
3
  end
@@ -28,4 +28,34 @@ class EqualityMatcherSpec
28
28
  defm it_can_check_inequality_with_alias_neq
29
29
  expect('foo').to_neq('bar')
30
30
  end
31
+
32
+ defm verify_type_mismatch(a, b)
33
+ try
34
+ expect(a).to_equal(b)
35
+ caught_error = false
36
+ catch /type mismatch/
37
+ ""get_logger().info(v:exception)
38
+ caught_error = true
39
+ end
40
+
41
+ expect(caught_error).to_be_true()
42
+ end
43
+
44
+ defm it_can_report_type_mismatch
45
+ self.verify_type_mismatch(100, 'one hundred')
46
+ self.verify_type_mismatch(1, '1')
47
+ self.verify_type_mismatch(0, '0')
48
+ self.verify_type_mismatch({}, [])
49
+ self.verify_type_mismatch({}, 'foo')
50
+ end
51
+
52
+ defm it_can_check_equality_of_lists
53
+ expect(['a', 'b']).to_not_equal(['a', 'b', 'c'])
54
+ expect(['a', 'b']).to_equal(['a', 'b'])
55
+ end
56
+
57
+ defm it_can_check_equality_of_dicts
58
+ expect({'foo': 10}).to_not_equal({'bar': 20})
59
+ expect({'foo': { 'bar': 10 }}).to_equal({'foo': { 'bar': 10 }})
60
+ end
31
61
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: speckle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darshan Sawardekar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-31 00:00:00.000000000 Z
11
+ date: 2013-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: riml