rad 0.2.2 → 0.2.9

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.
Files changed (123) hide show
  1. data/History.txt +34 -0
  2. data/Manifest.txt +113 -7
  3. data/{README.txt → README.rdoc} +17 -5
  4. data/Rakefile +3 -0
  5. data/bin/rad +106 -1
  6. data/lib/examples/add_hysteresis.rb +13 -0
  7. data/lib/examples/basic_blink.rb +10 -0
  8. data/lib/examples/blink_m_address_assignment.rb +104 -0
  9. data/lib/examples/blink_m_hello.rb +14 -0
  10. data/lib/examples/blink_m_multi.rb +61 -0
  11. data/lib/examples/blink_with_serial.rb +16 -0
  12. data/lib/examples/configure_pa_lcd_boot.rb +91 -0
  13. data/lib/examples/debounce_methods.rb +49 -0
  14. data/lib/examples/external_variable_fu.rb +26 -0
  15. data/lib/examples/external_variables.rb +32 -0
  16. data/lib/examples/first_sound.rb +23 -0
  17. data/lib/examples/frequency_generator.rb +30 -0
  18. data/lib/examples/hello_array.rb +48 -0
  19. data/lib/examples/hello_array2.rb +79 -0
  20. data/lib/examples/hello_array_eeprom.rb +59 -0
  21. data/lib/examples/hello_clock.rb +84 -0
  22. data/lib/examples/hello_eeprom.rb +51 -0
  23. data/lib/examples/hello_eeprom_lcdpa.rb +81 -0
  24. data/lib/examples/hello_format_print.rb +94 -0
  25. data/lib/examples/hello_lcd_charset.rb +75 -0
  26. data/lib/examples/hello_pa_lcd.rb +59 -0
  27. data/lib/examples/hello_servos.rb +88 -0
  28. data/lib/examples/hello_spectra_sound.rb +38 -0
  29. data/lib/examples/hello_world.rb +11 -0
  30. data/lib/examples/hello_xbee.rb +12 -0
  31. data/lib/examples/hysteresis_duel.rb +39 -0
  32. data/lib/examples/i2c_with_clock_chip.rb +124 -0
  33. data/lib/examples/midi_beat_box.rb +86 -0
  34. data/lib/examples/midi_scales.rb +94 -0
  35. data/lib/examples/motor_knob.rb +30 -0
  36. data/lib/examples/servo_buttons.rb +23 -0
  37. data/lib/examples/servo_calibrate_continuous.rb +92 -0
  38. data/lib/examples/servo_throttle.rb +40 -0
  39. data/lib/examples/sparkfun_lcd.rb +48 -0
  40. data/lib/examples/spectra_soft_pot.rb +34 -0
  41. data/lib/examples/times_method.rb +8 -0
  42. data/lib/examples/toggle.rb +10 -0
  43. data/lib/examples/twitter.rb +57 -0
  44. data/lib/examples/two_wire.rb +14 -0
  45. data/lib/libraries/AFSoftSerial/AFSoftSerial.cpp +321 -0
  46. data/lib/libraries/AFSoftSerial/AFSoftSerial.h +61 -0
  47. data/lib/libraries/AFSoftSerial/keywords.txt +18 -0
  48. data/lib/libraries/AF_XPort/AF_XPort.cpp +166 -0
  49. data/lib/libraries/AF_XPort/AF_XPort.h +48 -0
  50. data/lib/libraries/DS1307/DS1307.cpp +162 -0
  51. data/lib/libraries/DS1307/DS1307.h +66 -0
  52. data/lib/libraries/{SWSerLCDpa → DS1307}/keywords.txt +1 -1
  53. data/lib/libraries/FrequencyTimer2/FrequencyTimer2.cpp +144 -0
  54. data/lib/libraries/FrequencyTimer2/FrequencyTimer2.h +42 -0
  55. data/lib/libraries/FrequencyTimer2/keywords.txt +22 -0
  56. data/lib/libraries/I2CEEPROM/I2CEEPROM.cpp +120 -0
  57. data/lib/libraries/I2CEEPROM/I2CEEPROM.h +70 -0
  58. data/lib/libraries/I2CEEPROM/keywords.txt +21 -0
  59. data/lib/libraries/LoopTimer/LoopTimer.cpp +35 -0
  60. data/lib/libraries/LoopTimer/LoopTimer.h +34 -0
  61. data/lib/libraries/LoopTimer/keywords.txt +27 -0
  62. data/lib/libraries/OneWire/OneWire.cpp +194 -0
  63. data/lib/libraries/OneWire/OneWire.h +63 -0
  64. data/lib/libraries/OneWire/keywords.txt +35 -0
  65. data/lib/libraries/OneWire/readme.txt +13 -0
  66. data/lib/libraries/SWSerLCDpa/SWSerLCDpa.cpp +93 -47
  67. data/lib/libraries/SWSerLCDpa/SWSerLCDpa.h +16 -9
  68. data/lib/libraries/SWSerLCDsf/SWSerLCDsf.cpp +311 -0
  69. data/lib/libraries/SWSerLCDsf/SWSerLCDsf.h +67 -0
  70. data/lib/libraries/Servo/Servo.cpp +192 -0
  71. data/lib/libraries/Servo/Servo.h +61 -0
  72. data/lib/libraries/Stepper/Stepper.cpp +220 -0
  73. data/lib/libraries/Stepper/Stepper.h +86 -0
  74. data/lib/libraries/Stepper/keywords.txt +28 -0
  75. data/lib/libraries/Wire/Wire.cpp +262 -0
  76. data/lib/libraries/Wire/Wire.h +67 -0
  77. data/lib/libraries/Wire/keywords.txt +31 -0
  78. data/lib/libraries/Wire/twi.h +57 -0
  79. data/lib/libraries/Wire/utility/twi.c +449 -0
  80. data/lib/libraries/Wire/utility/twi.h +57 -0
  81. data/lib/plugins/bitwise_ops.rb +54 -0
  82. data/lib/plugins/blink.rb +25 -0
  83. data/lib/plugins/blink_m.rb +356 -0
  84. data/lib/plugins/debounce.rb +138 -0
  85. data/lib/plugins/debug_output_to_lcd.rb +71 -0
  86. data/lib/plugins/hysteresis.rb +52 -0
  87. data/lib/plugins/input_output_state.rb +84 -0
  88. data/lib/plugins/lcd_padding.rb +58 -0
  89. data/lib/plugins/mem_test.rb +37 -0
  90. data/lib/plugins/midi.rb +60 -0
  91. data/lib/plugins/parallax_ping.rb +50 -0
  92. data/lib/plugins/servo_pulse.rb +31 -0
  93. data/lib/plugins/servo_setup.rb +86 -0
  94. data/lib/plugins/smoother.rb +54 -0
  95. data/lib/plugins/spark_fun_serial_lcd.rb +100 -0
  96. data/lib/plugins/spectra_symbol.rb +79 -0
  97. data/lib/plugins/twitter_connect.rb +145 -0
  98. data/lib/rad/README.rdoc +5 -0
  99. data/lib/rad/arduino_plugin.rb +246 -0
  100. data/lib/rad/arduino_sketch.rb +351 -257
  101. data/lib/rad/generators/makefile/makefile.erb +1 -1
  102. data/lib/rad/generators/makefile/makefile.rb +9 -10
  103. data/lib/rad/hardware_library.rb +813 -0
  104. data/lib/rad/init.rb +3 -1
  105. data/lib/rad/rad_processor.rb +128 -0
  106. data/lib/rad/rad_rewriter.rb +94 -0
  107. data/lib/rad/rad_type_checker.rb +26 -0
  108. data/lib/rad/sim/arduino_sketch.rb +57 -0
  109. data/lib/rad/sketch_compiler.rb +47 -0
  110. data/lib/rad/tasks/build_and_make.rake +146 -24
  111. data/lib/rad/variable_processing.rb +153 -0
  112. data/lib/rad/version.rb +1 -1
  113. data/spec/examples/hello_world.rb +11 -0
  114. data/spec/examples/serial_motor.rb +12 -0
  115. data/spec/models/sketch_compiler_spec.rb +96 -0
  116. data/spec/sim/hello_world_spec.rb +42 -0
  117. data/test/test_array_processing.rb +179 -0
  118. data/test/test_plugin_loading.rb +151 -0
  119. data/test/test_translation_post_processing.rb +185 -0
  120. data/test/test_variable_processing.rb +238 -0
  121. data/website/index.html +22 -7
  122. data/website/stylesheets/screen.css +32 -1
  123. metadata +130 -13
@@ -0,0 +1,151 @@
1
+ #!/usr/local/bin/ruby -w
2
+
3
+ $TESTING = true
4
+
5
+ # this is a test stub for now
6
+ # lets review these
7
+ # neee to remove this constant from tests and pull it from rad
8
+ PLUGIN_C_VAR_TYPES = "int|void|unsigned|long|short|uint8_t|static|char\\*|byte"
9
+
10
+ require "rubygems"
11
+ require "#{File.expand_path(File.dirname(__FILE__))}/../lib/rad/rad_processor.rb"
12
+ require "#{File.expand_path(File.dirname(__FILE__))}/../lib/rad/rad_rewriter.rb"
13
+ require "#{File.expand_path(File.dirname(__FILE__))}/../lib/rad/rad_type_checker.rb"
14
+ require "#{File.expand_path(File.dirname(__FILE__))}/../lib/rad/variable_processing"
15
+ require "#{File.expand_path(File.dirname(__FILE__))}/../lib/rad/arduino_sketch"
16
+ require "#{File.expand_path(File.dirname(__FILE__))}/../lib/rad/arduino_plugin"
17
+ require 'test/unit'
18
+
19
+
20
+
21
+
22
+ class TestPluginLoading < Test::Unit::TestCase
23
+
24
+
25
+
26
+
27
+ def setup
28
+ $external_var_identifiers = ["__foo", "__toggle", "wiggle"]
29
+ $define_types = { "KOOL" => "long", "ZAK" => "str"}
30
+ $array_types = { "my_array" => "int"}
31
+ $plugin_directives = []
32
+ $plugin_external_variables = []
33
+ $plugin_signatures =[]
34
+ $plugin_methods = []
35
+ $add_to_setup = []
36
+ $load_libraries = []
37
+ $plugin_structs = {}
38
+ $plugin_methods_hash = {}
39
+ $plugins_to_load = []
40
+ plugin_signatures = []
41
+ plugin_methods = []
42
+
43
+ @plugin_string =<<-STR
44
+ class PluginTesting < ArduinoPlugin
45
+
46
+
47
+
48
+ #
49
+ #
50
+ # BlinkM_funcs.h -- Arduino library to control BlinkM
51
+ # --------------
52
+ #
53
+ #
54
+ # Note: original version of this file lives with the BlinkMTester sketch
55
+ #
56
+ # 2007, Tod E. Kurt, ThingM, http://thingm.com/
57
+ #
58
+ # version: 20080203
59
+ #
60
+ # history:
61
+ # 20080101 - initial release
62
+ # 20080203 - added setStartupParam(), bugfix receiveBytes() from Dan Julio
63
+ # 20080727 - ported to rad jd barnhart
64
+ #
65
+ # first step, declare output pin 19 as i2c
66
+ ## output_pin 19, :as => :wire, :device => :i2c, :enable => :true # reminder, true issues wire.begin
67
+
68
+
69
+ include_wire
70
+
71
+ add_blink_m_struct
72
+
73
+
74
+
75
+ # Not needed when pin is declared with :enable => :true
76
+
77
+ static int BlinkM_sendBack(byte addr)
78
+ {
79
+ int num = 0x11;
80
+ char buf[5];
81
+ itoa(num, buf, 16);
82
+ return "cool"
83
+ }
84
+
85
+ static char* another_method(byte addr)
86
+ {
87
+ int num = 0x11;
88
+ char buf[5];
89
+ itoa(num, buf, 16);
90
+ return "cool"
91
+ }
92
+
93
+ end
94
+ STR
95
+
96
+ @sketch_string =<<-STR
97
+ class SanMiquel < ArduinoSketch
98
+
99
+ # looking for hints? check out the examples directory
100
+ # example sketches can be uploaded to your arduino with
101
+ # rake make:upload sketch=examples/hello_world
102
+ # just replace hello_world with other examples
103
+
104
+ def loop
105
+ delay 100
106
+ my_lcd.home "k"
107
+ my_lcd.setxy 0,1
108
+
109
+ BlinkM_sendBack 10
110
+ delay 1000
111
+ test_address
112
+ end
113
+
114
+
115
+ end
116
+
117
+ STR
118
+
119
+ end
120
+
121
+ # remove these external variables and parens on variables
122
+ # need to actually run code through ruby_to_c for some of these tests
123
+
124
+ def test_int
125
+ name = "foo_a"
126
+ # check_for_plugin_use(sketch_string, plugin_string, file_name)
127
+ ArduinoPlugin.check_for_plugin_use(@sketch_string, @plugin_string, "hello_plugins")
128
+ value_string = "int(__toggle = 0);"
129
+ expected = ["hello_plugins"]
130
+ result = $plugins_to_load
131
+ assert_equal(expected, result)
132
+ end
133
+
134
+ def test_two
135
+ name = "foo_a"
136
+ # check_for_plugin_use(sketch_string, plugin_string, file_name)
137
+ ArduinoPlugin.check_for_plugin_use(@sketch_string, @plugin_string, "hello_plugins")
138
+ value_string = "int(__toggle = 0);"
139
+ expected = {"hello_plugins"=>["BlinkM_sendBack", "another_method"]}
140
+ result = $plugin_methods_hash
141
+ assert_equal(expected, result)
142
+ end
143
+
144
+
145
+
146
+ ## need to look at unsigned long
147
+ ## need parens removal tests
148
+
149
+
150
+
151
+ end
@@ -0,0 +1,185 @@
1
+ #!/usr/local/bin/ruby -w
2
+
3
+ $TESTING = true
4
+
5
+ # this is a test stub for now
6
+ # lets review these
7
+ # neee to remove this constant from tests and pull it from rad
8
+ C_VAR_TYPES = "unsigned|int|long|double|str|char|byte|float|bool"
9
+ require "rubygems"
10
+ require "#{File.expand_path(File.dirname(__FILE__))}/../lib/rad/rad_processor.rb"
11
+ require "#{File.expand_path(File.dirname(__FILE__))}/../lib/rad/rad_rewriter.rb"
12
+ require "#{File.expand_path(File.dirname(__FILE__))}/../lib/rad/rad_type_checker.rb"
13
+ require "#{File.expand_path(File.dirname(__FILE__))}/../lib/rad/variable_processing"
14
+ require "#{File.expand_path(File.dirname(__FILE__))}/../lib/rad/arduino_sketch"
15
+ require 'test/unit'
16
+
17
+
18
+ class TranslationTesting < ArduinoSketch
19
+
20
+ def one
21
+ delay 1
22
+ end
23
+
24
+ def two
25
+ delay 1
26
+ @foo = 1
27
+ end
28
+
29
+ def three
30
+ @foo = 1
31
+ bar = 2
32
+ baz = wha
33
+ end
34
+
35
+ def four
36
+ @foo = 1
37
+ bar = 2
38
+ wiggle = wha
39
+ end
40
+
41
+ def five
42
+ @foo = 1
43
+ f = KOOL
44
+ end
45
+
46
+ def six
47
+ a = ZAK
48
+
49
+ end
50
+
51
+ def seven(int)
52
+ # coerce int to long int
53
+ a = int * 2
54
+ end
55
+
56
+ def eight(str)
57
+ # coerce str to string
58
+ a = ZAK + str
59
+ end
60
+
61
+ def nine
62
+ @my_array.each do |a|
63
+ delay a
64
+ end
65
+ end
66
+
67
+
68
+ end
69
+
70
+
71
+
72
+ class TestTranslationPostProcessing < Test::Unit::TestCase
73
+
74
+
75
+
76
+
77
+ def setup
78
+ $external_var_identifiers = ["__foo", "__toggle", "wiggle"]
79
+ $define_types = { "KOOL" => "long", "ZAK" => "str"}
80
+ $array_types = { "my_array" => "int"}
81
+
82
+
83
+ end
84
+
85
+ # remove these external variables and parens on variables
86
+ # need to actually run code through ruby_to_c for some of these tests
87
+
88
+ def test_int
89
+ name = "foo_a"
90
+ value_string = "int(__toggle = 0);"
91
+ expected = ""
92
+ result = ArduinoSketch.post_process_ruby_to_c_methods(value_string)
93
+ assert_equal(expected, result)
94
+ end
95
+
96
+ def test_bool
97
+ name = "foo_b"
98
+ value_string = "bool(__toggle = 0);"
99
+ expected = ""
100
+ result = ArduinoSketch.post_process_ruby_to_c_methods(value_string)
101
+ assert_equal(expected, result)
102
+ end
103
+
104
+ def test_long
105
+ name = "foo_c"
106
+ value_string = "long(__foo = 0);"
107
+ expected = ""
108
+ result = ArduinoSketch.post_process_ruby_to_c_methods(value_string)
109
+ assert_equal(expected, result)
110
+ end
111
+
112
+ def test_trans_one
113
+ name = "foo_d"
114
+ expected = "void\none() {\ndelay(1);\n}"
115
+ result = raw_rtc_meth = RADProcessor.translate(TranslationTesting, "one")
116
+ assert_equal(expected, result)
117
+ end
118
+
119
+ # notice the nice behavior of @foo
120
+ def test_trans_two
121
+ name = "foo_e"
122
+ expected = "void\ntwo() {\ndelay(1);\n__foo = 1;\n}"
123
+ result = raw_rtc_meth = RADProcessor.translate(TranslationTesting, "two")
124
+ assert_equal(expected, result)
125
+ end
126
+
127
+ # notice the nice behavior of @foo
128
+ def test_trans_three
129
+ name = "foo_f"
130
+ expected = "void\nthree() {\nlong bar;\nvoid * baz;\n__foo = 1;\nbar = 2;\nbaz = wha();\n}"
131
+ result = raw_rtc_meth = RADProcessor.translate(TranslationTesting, "three")
132
+ assert_equal(expected, result)
133
+ end
134
+
135
+ # need to take a closer look at this ... include "void * wiggle" regex?
136
+ #
137
+ def test_trans_four
138
+ name = "foo_f"
139
+ expected = "void\nfour() {\nlong bar;\nvoid * wiggle;\n__foo = 1;\nbar = 2;\nwiggle = wha();\n}"
140
+ result = raw_rtc_meth = RADProcessor.translate(TranslationTesting, "four")
141
+ assert_equal(expected, result)
142
+ end
143
+
144
+ def test_trans_five
145
+ name = "foo_f"
146
+ expected = "void\nfive() {\nlong f;\n__foo = 1;\nf = KOOL;\n}"
147
+ result = raw_rtc_meth = RADProcessor.translate(TranslationTesting, "five")
148
+ assert_equal(expected, result)
149
+ end
150
+
151
+ def test_trans_six
152
+ name = "foo_f"
153
+ expected = "void\nsix() {\nstr a;\na = ZAK;\n}"
154
+ result = raw_rtc_meth = RADProcessor.translate(TranslationTesting, "six")
155
+ assert_equal(expected, result)
156
+ end
157
+
158
+ def test_trans_seven
159
+ name = "foo_f"
160
+ expected = "void\nseven(long int) {\nlong a;\na = int * 2;\n}"
161
+ result = raw_rtc_meth = RADProcessor.translate(TranslationTesting, "seven")
162
+ assert_equal(expected, result)
163
+ end
164
+
165
+ def test_trans_eight
166
+ name = "foo_f"
167
+ expected = "void\neight(long str) {\nvoid * a;\na = ZAK + str;\n}"
168
+ result = raw_rtc_meth = RADProcessor.translate(TranslationTesting, "eight")
169
+ assert_equal(expected, result)
170
+ end
171
+
172
+ def test_trans_nine
173
+ name = "foo_f"
174
+ expected = "void\nnine() {\nunsigned int index_a;\nfor (index_a = 0; index_a < (int) (sizeof(__my_array) / sizeof(__my_array[0])); index_a++) {\nint a = __my_array[index_a];\ndelay(a);\n}\n}"
175
+ result = raw_rtc_meth = RADProcessor.translate(TranslationTesting, "nine")
176
+ assert_equal(expected, result)
177
+ end
178
+
179
+
180
+ ## need to look at unsigned long
181
+ ## need parens removal tests
182
+
183
+
184
+
185
+ end
@@ -0,0 +1,238 @@
1
+ #!/usr/local/bin/ruby -w
2
+
3
+ $TESTING = true
4
+
5
+ # need to tell it where we are
6
+ # lets review these
7
+ # neee to remove this constant from tests and pull it from rad
8
+ C_VAR_TYPES = "unsigned|int|long|double|str|char|byte|float|bool"
9
+ require "#{File.expand_path(File.dirname(__FILE__))}/../lib/rad/variable_processing"
10
+ require "#{File.expand_path(File.dirname(__FILE__))}/../lib/rad/arduino_sketch"
11
+ require 'test/unit'
12
+
13
+
14
+
15
+ class TestVariableProcessing < Test::Unit::TestCase
16
+
17
+ def setup
18
+ @t = ArduinoSketch.new
19
+ end
20
+
21
+ # question for brian... do we need variable assignment with no value when
22
+ # we have "" and 0
23
+
24
+
25
+
26
+ def test_int_as_int
27
+ name = "foo_a"
28
+ value_string = 1
29
+ expected = "int __foo_a = 1;"
30
+ result = @t.pre_process_vars(name, value_string)
31
+ assert_equal(expected, result[0])
32
+ end
33
+
34
+ def test_string_as_int
35
+ name = "foo_b"
36
+ value_string = "1"
37
+ expected = "int __foo_b = 1;"
38
+ result = @t.pre_process_vars(name, value_string)
39
+ assert_equal(expected, result[0])
40
+ end
41
+
42
+ def test_float_as_float
43
+ name = "foo_c"
44
+ value_string = 0.10
45
+ expected = "float __foo_c = 0.1;"
46
+ result = @t.pre_process_vars(name, value_string)
47
+ assert_equal(expected, result[0])
48
+ end
49
+
50
+ def test_string_as_float
51
+ name = "foo_d"
52
+ value_string = "0.10"
53
+ expected = "float __foo_d = 0.1;"
54
+ result = @t.pre_process_vars(name, value_string)
55
+ assert_equal(expected, result[0])
56
+ end
57
+
58
+ def test_byte # would this to return hex
59
+ name = "foo_f"
60
+ value_string = 0x00
61
+ expected = "int __foo_f = 0;"
62
+ result = @t.pre_process_vars(name, value_string)
63
+ assert_equal(expected, result[0])
64
+ end
65
+
66
+ def test_byte_with_string_input
67
+ name = "foo_g"
68
+ value_string = "0x00"
69
+ expected = "byte __foo_g = 0x00;"
70
+ result = @t.pre_process_vars(name, value_string)
71
+ assert_equal(expected, result[0])
72
+ end
73
+
74
+ def test_string
75
+ name = "foo_h"
76
+ value_string = "arduino"
77
+ expected = "char* __foo_h = \"arduino\";"
78
+ result = @t.pre_process_vars(name, value_string)
79
+ assert_equal(expected, result[0])
80
+ end
81
+
82
+ def test_int_with_type
83
+ name = "foo_i"
84
+ value_string = "int"
85
+ expected = "int __foo_i;"
86
+ result = @t.pre_process_vars(name, value_string)
87
+ assert_equal(expected, result[0])
88
+ end
89
+
90
+ def test_odd_name
91
+ name = "bacon_j"
92
+ value_string = "arduino"
93
+ expected = "char* __bacon_j = \"arduino\";"
94
+ result = @t.pre_process_vars(name, value_string)
95
+ assert_equal(expected, result[0])
96
+ end
97
+
98
+ def test_int_with_type_two
99
+ name = "foo_k"
100
+ value_string = "2, int"
101
+ expected = "int __foo_k = 2;"
102
+ result = @t.pre_process_vars(name, value_string)
103
+ assert_equal(expected, result[0])
104
+ end
105
+
106
+ def test_int_with_long
107
+ name = "foo_l"
108
+ value_string = "2, int"
109
+ expected = "int __foo_l = 2;"
110
+ result = @t.pre_process_vars(name, value_string)
111
+ assert_equal(expected, result[0])
112
+ end
113
+
114
+ def test_int_with_byte
115
+ name = "foo_m"
116
+ value_string = "2, byte"
117
+ expected = "byte __foo_m = 2;"
118
+ result = @t.pre_process_vars(name, value_string)
119
+ assert_equal(expected, result[0])
120
+ end
121
+
122
+ def test_int_with_unsigned_int
123
+ name = "foo_n"
124
+ value_string = "2, unsigned int"
125
+ expected = "unsigned int __foo_n = 2;"
126
+ result = @t.pre_process_vars(name, value_string)
127
+ assert_equal(expected, result[0])
128
+ end
129
+
130
+ def test_int_with_unsigned_long
131
+ name = "foo_o"
132
+ value_string = "2, unsigned long"
133
+ expected = "unsigned long __foo_o = 2;"
134
+ result = @t.pre_process_vars(name, value_string)
135
+ assert_equal(expected, result[0])
136
+ end
137
+
138
+ def test_int_with_short_int
139
+ name = "foo_q"
140
+ value_string = "2, short int"
141
+ expected = "short int __foo_q = 2;"
142
+ result = @t.pre_process_vars(name, value_string)
143
+ assert_equal(expected, result[0])
144
+ end
145
+
146
+ def test_int_with_unsigned_short_int
147
+ name = "foo_r"
148
+ value_string = "2, unsigned short int"
149
+ expected = "unsigned short int __foo_r = 2;"
150
+ result = @t.pre_process_vars(name, value_string)
151
+ assert_equal(expected, result[0])
152
+ end
153
+
154
+ def test_float_with_type
155
+ name = "foo_s"
156
+ value_string = "2.0, float"
157
+ expected = "float __foo_s = 2.0;"
158
+ result = @t.pre_process_vars(name, value_string)
159
+ assert_equal(expected, result[0])
160
+ end
161
+
162
+ def test_true
163
+ name = "foo_t"
164
+ value_string = true
165
+ expected = "bool __foo_t = 1;"
166
+ result = @t.pre_process_vars(name, value_string)
167
+ assert_equal(expected, result[0])
168
+ end
169
+
170
+ def test_false
171
+ name = "foo_v"
172
+ value_string = false
173
+ expected = "bool __foo_v = 0;"
174
+ result = @t.pre_process_vars(name, value_string)
175
+ assert_equal(expected, result[0])
176
+ end
177
+
178
+ def test_negative_int_string
179
+ name = "foo_w"
180
+ value_string = "-1, int"
181
+ expected = "int __foo_w = -1;"
182
+ result = @t.pre_process_vars(name, value_string)
183
+ assert_equal(expected, result[0])
184
+ end
185
+
186
+ def test_negative_float_string
187
+ name = "foo_x"
188
+ value_string = "-0.1, float"
189
+ expected = "float __foo_x = -0.1;"
190
+ result = @t.pre_process_vars(name, value_string)
191
+ assert_equal(expected, result[0])
192
+ end
193
+
194
+ def test_negative_larger_float_string
195
+ name = "foo_y"
196
+ value_string = "-1000.01, float"
197
+ expected = "float __foo_y = -1000.01;"
198
+ result = @t.pre_process_vars(name, value_string)
199
+ assert_equal(expected, result[0])
200
+ end
201
+
202
+ def test_negative_long_string
203
+ name = "foo_z"
204
+ value_string = "-.0991, float"
205
+ expected = "float __foo_z = -0.0991;"
206
+ result = @t.pre_process_vars(name, value_string)
207
+ assert_equal(expected, result[0])
208
+ end
209
+
210
+ def test_negative_float_string_two
211
+ name = "foo_aa"
212
+ value_string = "-.01, float"
213
+ expected = "float __foo_aa = -0.01;"
214
+ result = @t.pre_process_vars(name, value_string)
215
+ assert_equal(expected, result[0])
216
+ end
217
+
218
+ def test_negative_interter_string
219
+ name = "foo_bb"
220
+ value_string = "-.01, float"
221
+ expected = "float __foo_bb = -0.01;"
222
+ result = @t.pre_process_vars(name, value_string)
223
+ assert_equal(expected, result[0])
224
+ end
225
+
226
+ def test_dash_string
227
+ name = "foo_cc"
228
+ value_string = "-hmmm"
229
+ expected = "char* __foo_cc = \"-hmmm\";"
230
+ result = @t.pre_process_vars(name, value_string)
231
+ assert_equal(expected, result[0])
232
+ end
233
+
234
+
235
+
236
+
237
+
238
+ end