This feed contains pages with tag "git".
Before the lab
- Complete the On your own part of L02
- Read FICS unit 3
- Read the first two sections of Stepper documentation
- Read the documentation for check-expect, check-random, check-satisfied, check-within, check-error, check-member-of, check-range
- Read FICS unit 3
Background
Questions from last time
- Time
- 10 Minutes
- Activity
- Group discussion
In this part of the lab, we will discuss some questions from the On your own part of L02.
Git
- What is a remote?
- What is merging?
- What is a conflict?
Setup
- make a directory
labs/L03
inside your~/cs2613
git repository - All of your work from today should be committed in that directory (and pushed before you leave).
The DrRacket stepper
- Time
- 20 min
- Activity
- Individual work
Unit testing is an important part of programming, and has inspired something called test driven development.
This part is based on an example from
RackUnit QuickStart.
- copy arith.rkt, save it as
~/cs2613/labs/L03/arith.rkt
and commit it.
run your
arith.rkt
inDrRacket
; observe that the test failsrun your
arith.rkt
in the DrRacket Stepper. Notice that after about 7 steps, we have reduced to a test case to multiplication by zero which looks wrong. That means that the problem is with the recursive (reduction) step.Fix the
a > 0
case ofmy-*
to match the following formulaa * b = (a - 1) * b + b
, while still usingmy-+
DrRacket should report "The test passed!" when you have it working. Commit this version of your code. Remember that git commit message quality counts in this course, so work on making commit messages.
Semantics
- Time
- 20 min
- Activity
- Small Groups
- Summary
- new evaluation rules for
and
andor
As you read in FICS unit
3,
we can understand evaluation ("running") of Racket programs as a
sequence of "reductions" or "substitutions". These rules are similar to the reduction steps in the DrRacket
stepper.
The stepper uses the following rules for and
and or
(notice that these rules enforce short circuit evaluation)
(and true exp2 ...) => (and exp2 ...)
(and false exp2 ...) => false
(or true exp2 ...) => true
(or false exp2 ...) => (or exp2 ...)
(and) => true
(or) => false
Following Exercise 7, write a new set of rules
that requires at least two arguments for and
and or
.
The rules are for human consumption; you can write them
as comments in DrRacket. You can write "exp1 exp2 ..." to mean at least 2 expressions.
Discuss your answers with a your group, and try a couple evaluation small examples by hand using your rules.
Test Coverage
- Time
- 25 min
- Activity
- Individual work
This activity continues
arith.rkt
from the first half of the lab.Under
Language -> Choose Language -> Show Details -> Dynamic Properties
enable
⊙ Syntactic test suite coverage
run your code in
DrRacket
againmost likely you will have some code highlighted with orange text and black foreground. This means that code is not covered by your test suite. Add another test to cover each piece of uncovered code.
When you have complete test coverage, commit your code.
In this course, for all
racket
assignments you will lose marks if you don't have complete test coverage.Push your repo to coursegit.
If you have extra time
- Run the tests on the command line with
raco test arith.rkt
- Read the first assignment A1
- Update your journal. Remember the first journal entry is due tommorow.
Reading for next lab
- Read FICS unit 4
On your own
- Time
- 20 min
- Activity
- Independent research
See if you can come up with answers to the following questions for next time.
The programming languages we will study this term are all dynamically typed. This means that not only the value but also the type of variables can change at runtime. Why does this make testing even more important?
What kind of software problems is testing not well suited to find?
Why might mutable state (e.g. instance variables in Java) make writing unit tests harder?