This feed contains pages with tag "git".
Before the lab
Reading
- 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
Git Practice: Working with multiple git repos
- Time
- 15-30 minutes
- Activity
- Individual work, outside scheduled lab time.
Cloning
Open a terminal.
Make a directory
lab2-scratch
somewhere outside thecs2613
git repository you created earlier.Now move to the
lab2-scratch
directory, and make a clone of the central repo.$ git clone -b main https://$username@vcs.cs.unb.ca/git/cs2613-$username cs2613-clone
This creates a new directory "cs2613-clone" containing a clone of your repository. Notice that in general this is a good way of checking that your work is properly submitted. The TA and Prof will do exactly this cloning step in order to mark your work. The clone is on an equal footing with the original project, possessing its own copy of the original project’s history.
Sharing changes with a central repo
Optional, but useful if you plan to run git on your own computer
Open a terminal
Navigate to the
~/lab2-scratch/cs2613-clone/journal
directory.create a new blog entry, and commit it.
Push your changes back to the central repository.
$ git push origin main
Change directory to your original directory
~/cs2613
. Bring in the changes you made$ git pull origin main
This merges the changes from the central copy of "main" branch into the current branch. If you made other changes in the meantime, then you may need to manually fix any conflicts.
The "pull" command thus performs two operations: it fetches changes from a remote branch, then merges them into the current branch.
Questions
Here are some questions we will be discussing at the beginning of L03.
- What is a remote?
- What is merging?
- What is a conflict?
Git next steps
Congratulations, you now know enough git to finish this course.
There is lots more to learn, particularly about branching and collaboration. If you want to get a big(ger) picture view, a good place to start is Git Concepts Simplified.
Git Questions
- Time
- 10 Minutes
- Activity
- Group discussion
Some questions from before:
- 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.
Before Next Lab
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?