Commits

Brett Giles  committed 42ceae8

100% test coverage.

And found that the depth multiplier was not hooked up - thereby giving the issue of results seeming to be off.

  • Participants
  • Parent commits fac9a21

Comments (0)

Files changed (10)

File GUI/spec/view/descriptor_painter_spec.rb

       check_raster_point_is_grey(rstr,19,19)
     end
     it "should draw the Value centered on the point with paint_value" do
-      @adp.paint_value(@d.gc,Point.new(20,10)) # adds node size to y real point is 20,20
+      @adp.paint_value(@d.gc,Point.new(20,0)) # adds 2*node size to y real point is 20,20
       rstr = @d.bi.data(Rectangle.new(0,0,30,30))
       check_raster_point_is_grey(rstr,19,19)
       check_raster_point_is_grey(rstr,21,19)
       check_raster_point_is_grey(rstr,19,19)
     end
     it "should draw the Value centered on the point with paint_value" do
-      @sd.paint_model_at_point(@d.gc,Point.new(20,10)) # adds node size to y real point is 20,20
+      @sd.paint_model_at_point(@d.gc,Point.new(20,0)) # adds 2*node size to get y real point is 20,20
       rstr = @d.bi.data(Rectangle.new(0,0,30,30))
       check_raster_point_is_grey(rstr,19,19)
       check_raster_point_is_grey(rstr,21,19)

File GUI/src/communications/connection.rb

     @my_path= File.expand_path(__FILE__)[Regexp.new /.*?jar!/]
     if @my_path
       #:nocov:
-      @my_path=@my_path[5,jar_path.length - 18] #remove 'file:' from front, lqpl_gui.jar! from back
+      @my_path=@my_path[5,@my_path.length - 18] #remove 'file:' from front, lqpl_gui.jar! from back
       #:nocov:
     else
       @my_path = File.expand_path(File.dirname(__FILE__))+"/../../"

File GUI/src/communications/lqpl_emulator_server_connection.rb

     send_and_receive_command("get dump #{recursion_depth}  #{tree_depth}\n")
   end
 
-  def do_step(step_size=1, depth=1)
-    send_and_receive_command "step #{step_size} #{depth}\n"
+  def do_step(step_size=1, recursion_depth=1)
+    send_and_receive_command "step #{step_size} #{recursion_depth}\n"
   end
 
   def do_run(recursion_depth=1)

File GUI/src/lqpl/lqpl_controller.rb

   end
 
   def help_about_action_performed
-    AboutController.instance.handle_about
+    AboutController.instance.handleAbout(nil)
   end
 
   def file_compile_action_performed
 
   def recursion_spinner_state_changed
     model.recursion_spinner = java.lang.Integer.new(view_model.recursion_spinner)
+    model.messages_text =  "Recursion Depth set to #{model.recursion_spinner}"
     enable_and_update true
   end
 
   def recursion_multiplier_spinner_state_changed
     model.recursion_multiplier_spinner = java.lang.Integer.new("#{view_model.recursion_multiplier_spinner}")
     lqpl_emulator_server_connection.send_set_depth_multiplier(model.recursion_multiplier_spinner)
+    model.messages_text =  "Recursion Multiplier set to #{model.recursion_multiplier_spinner}"
     enable_and_update true
   end
   
 
   def tree_depth_spinner_state_changed
     model.tree_depth_spinner = java.lang.Integer.new(view_model.tree_depth_spinner)
+    model.messages_text =  "Tree Depth set to #{model.tree_depth_spinner}"
+    update_view
     update_sub_model_data
   end
 

File GUI/src/lqpl/lqpl_view.rb

 
   map :view => "stepSpinner.model.value", :model => :step_spinner
   map :view => "recursionSpinner.model.value", :model => :recursion_spinner
+  map :view => "recursionMultiplierSpinner.model.value", :model => :recursion_multiplier_spinner
   map :view => "treeDepthSpinner.model.value", :model => :tree_depth_spinner
 
   map :view => "messagesTextArea.text", :model => :messages_text

File GUI/testdata/qplprograms/recurse.qpo

+Compiler: Version=0.9.0
+main   Start
+EnScope
+    Call 0 one_to_2_fcdlbl0
+    Rename @c @a
+DeScope
+   EndProc
+one_to_2_fcdlbl0   Start
+EnScope
+    QLoad @q |0>
+    QApply 0 !Had @q
+    QPullup @q
+EnScope
+    Measure @q lbl2 lbl0 lbl1
+lbl0     QDiscard @q
+    CLoad 1
+    QMove @c
+    SwapD   
+lbl1     QDiscard @q
+    Call 0 one_to_2_fcdlbl0
+    SwapD   
+lbl2 DeScope
+DeScope
+    Return 0
+   EndProc

File features/change_depth_spinners.feature

+Feature: We can change the call depth and multiplier
+  The call depth controls how many calls the emulator will do before specifying the 
+  result as undefined. The deeper the call depth, the better the approximation of
+  the end result. However, the deeper the call depth, the more compute power used by the
+  emulator.
+  Additionally, the emulator can be set to use a multiplier for each approximation. For
+  example, it can allow 20 calls per level. This is much cheaper computationally than 
+  just displaying the 20th level where each one is a single call allowed.
+  The GUI allows complete control over both these settings
+
+  Background:
+	  When I select "Load" from the "File" menu
+    And I load "recurse.qpo" from the project directory "GUI/testdata/qplprograms"
+
+  Scenario: I can set the multiplier to 1 by typing in the field
+    Given I type "1" in the "Recursion Multiplier" field
+    Then the messages field should contain:
+      |partial|
+      |Recursion Multiplier set|
+
+  Scenario: I can set the recursion depth to 4 by typing in the field
+    Given I type "4" in the "Recursion Depth" field
+    Then the messages field should contain:
+      |partial|
+      |Recursion Depth set|
+
+  Scenario: I can set the tree depth to 10 by typing in the field
+    Given I type "10" in the "Tree Depth" field
+    Then the messages field should contain:
+      |partial|
+      |Tree Depth set|
+
+  Scenario: I can set the multiplier to 4 by typing in the field and then clicking
+    Given I type "1" in the "Recursion Multiplier" field
+    And I click the up on the "Recursion Multiplier" spinner 3 times
+    Then the messages field should contain:
+      |partial|
+      |Recursion Multiplier set to 4|
+
+  Scenario: I can set the recursion depth to 4 by typing in the field and then clicking
+    Given I type "1" in the "Recursion Depth" field
+    And I click the up on the "Recursion Depth" spinner 3 times
+    Then the messages field should contain:
+      |partial|
+      |Recursion Depth set to 4|
+
+  Scenario: I can set the tree depth to 5 by typing in the field and then clicking
+    Given I type "10" in the "Tree Depth" field
+    And I click the down on the "Tree Depth" spinner 5 times
+    Then the messages field should contain:
+      |partial|
+      |Tree Depth set to 5|

File features/load_an_assembled_qpo.feature

 	  When I select "Load" from the "File" menu
     And I load "coin.reference.qpo" from the project directory "GUI/testdata/qplprograms"
     
-
   Scenario:
     Then the main frame's title should be "Quantum Emulator - coin.reference.qpo"
     Then the button "Step" should appear
     Then the button "Go" should appear
     Then the button "Trim" should appear
-    Then the number spinner "Step Size" should appear and have value "1"
-    Then the number spinner "Recursion Depth" should appear and have value "1"
-    Then the number spinner "Recursion Multiplier" should appear and have value "10"
-    Then the number spinner "Tree Depth" should appear and have value "4"
+    Then the number spinner "Step Size" should appear
+    Then the number spinner "Recursion Depth" should appear
+    Then the number spinner "Recursion Multiplier" should appear
+    Then the number spinner "Tree Depth" should appear
     Then the frame "Quantum Stack" should be visible
 
   Scenario:

File features/step_definitions/change_depth_spinners.rb

+
+Given /^I type "(\d+)" in the "(.*?)" field$/ do |val,field_name|
+  spinner = spinner_for_label field_name
+  spinner.enter_text_and_commit val
+end
+
+Given /^I click the (up|down) on the "(.*?)" spinner (\d+) times?$/ do |up_down,field_name, count|
+  spinner = spinner_for_label field_name
+  spinner.increment(count.to_i) if up_down == "up"
+  spinner.decrement(count.to_i) if up_down == "down"
+end

File features/step_definitions/load_an_assembled_qpo.rb

 end
 
 Then /^the number spinner "([\w\s]*)" should appear and have value "([\d]*)"$/ do |spinner_label, spin_value|
-  theSpinner = spinner_for_label(spinner_label)
-  theSpinner.should_not == nil
-  theSpinner.should be_edt_visible
-  theSpinner.text.should == "#{spin_value}"
+  spinner = spinner_for_label(spinner_label)
+  spinner.should_not == nil
+  spinner.should be_edt_visible
+  spinner.text.should == "#{spin_value}"
+end
+
+
+Then /^the number spinner "([\w\s]*)" should appear$/ do |spinner_label|
+  spinner = spinner_for_label(spinner_label)
+  spinner.should_not == nil
+  spinner.should be_edt_visible
 end
 
 Then /^the frame "([\w\s]*)" should (be|not be) visible$/ do |frame_title,visible|
 
 Then /^I click the spinner "([\w\s]*)" (up|down) (\d)* times? on the frame "([\w\s]*)"$/ do |spinner_label, direction, count, frame_title|
   frame_ref=set_and_return_frame_fixture(frame_title)
-  theSpinner = spinner_for_label(spinner_label,frame_ref)
-  theSpinner.increment(count.to_i) if direction == "up"
-  theSpinner.decrement(count.to_i) if direction == "down"
+  spinner = spinner_for_label(spinner_label,frame_ref)
+  spinner.increment(count.to_i) if direction == "up"
+  spinner.decrement(count.to_i) if direction == "down"
   
 end