Updating-a-Stubbed-Out-Function

Updating a Stubbed-Out Function

Updating a Stubbed-Out Function

You have now revised the gp:getDialogInput function. Whenever you modify a stubbed-out function, you should always check a couple
of things:

  • Has the defun statement changed? That is, does the function still take the same number of arguments?
  • Does the function return something different?

In the case of gp:getDialogInput, the answer to both questions is yes. The function now accepts the parameter of the
path width (to set the default tile size and spacing). And instead of returning T, which is the value the stubbed-out version of the function returned, gp:getDialogInput now returns an association list containing four new values.

Both changes affect the code that calls the function and the code that handles the
return values from the functions. Replace your previous version of the C:GPath function in gpmain.lsp with the following code:

(defun C:GPath (/ gp_PathData gp_dialogResults)
  ;; Ask the user for input: first for path location and
  ;; direction, then for path parameters.  Continue only if you
  ;; have valid input.  Store the data in gp_PathData.
  (if (setq gp_PathData (gp:getPointInput))
    (if (setq gp_dialogResults (gp:getDialogInput (cdr(assoc 40
                               gp_PathData))))
      (progn
        ;; Now take the results of gp:getPointInput and append this
        ;; to the added information supplied by gp:getDialogInput.
        (setq gp_PathData (append gp_PathData gp_DialogResults))

        ;; At this point, you have all the input from the user.
        ;; Draw the outline, storing the resulting polyline
        ;; "pointer" in the variable called PolylineName.
        (setq PolylineName (gp:drawOutline gp_PathData))
      ) ;_ end of progn
      (princ "
Function cancelled.")

    ) ;_ end of if
    (princ "
Incomplete information to draw a boundary.")

  ) ;_ end of if
  (princ)  ; exit quietly

) ;_ end of defun

Take a look at the boldface lines in the revision of the main C:GPath function. There are two essential changes to make the program work correctly:

  • When the gp:getDialogInput function is invoked, the path width is passed to it. This is done by extracting the
    value associated with the key 40 index of the gp_PathData association list.
  • The association list returned by gp:getPointInput is assigned to a variable called gp_dialogResults. If this variable has a value, its content needs to be appended to the association
    list values already stored in gp_PathData.

There are additional changes in the code resulting from the replacement of placeholders
in the stubbed-out version. The easiest thing to do is copy this code from the online
tutorial and paste it into your file.

Learning AutoCad

u have now revised the gp:getDialogInput function. Whenever you modify a stubbedout function, you should always check a couple of things: Has the defun  …update my answer to mention this. – Retsam Jun 19 '14 at …Stubbed out timer objects for fast unit testing in nodejs. … josephg committed on GitHub Update README.md … version of setInterval , clearInterval , setTimeout , clearTimeout and Date.now (through a wrapped Date function).… I was expecting to then be able to call update on the wrapper, simulate an action, and then assert that the stub was actually called. … components internal handleSubmit method', function() { const props … Testing a react-form, handleSubmit method stubbing #۷۱۵ … You signed out in another tab or window.stub a function with two input pointers: [<code>] … The function takes the address of a variable and updates the variable.updated almost 3 years ago; RSpec, stubs, mocks, … As with a normal double, you can stub out any methods on …stubbing FOO" do it "can stub FOO with a different value" do stub_const("FOO", 5) FOO.should eq(5) end it "restores the stubbed constant …stubbed HTTP responses to specific requests.… We stubbed out the file with a static initializer that returns a generated cat sprite. We also stubbed out another update function. If we need to …

نظرات کاربران



درباره نویسنده



بنده سیامک دوستداری فارغ التحصیل رشته مکانیک سنگ از دانشگاه صنعتی اصفهان هستم، و در این وبسایت آموزش های مربوط به نحوه برنامه نویسی در اتوکد و هچنین آموزش تصویری دستورات اتوکد را قرار خواهم داد.

تلفن همراه: ۰۹۰۰۱۲۳۴۴۴۴

ایمیل: s.doostdari@gmail.com

ترفند های اتوکد



دسته بندی مطالب​