Why are "make-" expressions truncated in DrRacket test results and failing?

2 years ago by appleberry to c/learn_programming

How can I compare truncated test results in DrRacket?

Actual value (make-ta ...) differs from (make-ta ...), the expected value.

aberrate_junior_beatnik 1 point 2 years ago

I'm not super familiar with DrRacket (when last I used it it was DrScheme, which should tell you how old I am). I downloaded it off flathub, DDG'd ta-solver-starter.rkt, ran it, and here's what I saw:

Not sure what to tell you!

path: 0 16460582, hotness: undefined, score: 1, children: 2
appleberry 2 points 2 years ago

I appreciate the effort! Further to this, I seems like if I change my function and the expected result to compare lists instead of 'make-ta' they pass!

(check-expect (sub-slot 1 SOBA) (make-ta "Soba" 1 (list 3))) ; subtract one shift <--- FAIL
(check-expect (sub-slot 3 SOBA) (make-ta "Soba" 1 (list 1))) ; subtract a different shift <--- FAIL

(define (sub-slot slot ta)
  (cond [(and (> (ta-max ta) 0) (> (length (ta-avail ta)) 1))
              (make-ta (ta-name ta) 
                       (sub1 (ta-max ta))
                       (remq slot (ta-avail ta)))]
              [else empty]))
(check-expect (sub-slot 1 SOBA) (make-ta "Soba" 1 (list 3))) ; subtract one shift <--- FAIL
(check-expect (sub-slot 3 SOBA) (list "Soba" 1 (list 1))) ; subtract a different shift <--- PASS

(define (sub-slot slot ta)
  (cond [(and (> (ta-max ta) 0) (> (length (ta-avail ta)) 1))
              (list (ta-name ta) 
                       (sub1 (ta-max ta))
                       (remq slot (ta-avail ta)))]
              [else empty]))

This is the final problem of the course 😅. I'm going to try and get to the bottom of this rather than work around with lists (which is what I did last time). I must have some misunderstanding with make- functions...

path: 0 16460582 16475155, hotness: undefined, score: 2, children: 1
appleberry 1 point 2 years ago path: 0 16460582 16475155 16516256, hotness: undefined, score: 1, children: 0
learn_programming
learn_programming

@programming.dev

login for more options
2260
161
46

Posting Etiquette

  1. Ask the main part of your question in the title. This should be concise but informative.

  2. Provide everything up front. Don't make people fish for more details in the comments. Provide background information and examples.

  3. Be present for follow up questions. Don't ask for help and run away. Stick around to answer questions and provide more details.

  4. Ask about the problem you're trying to solve. Don't focus too much on debugging your exact solution, as you may be going down the wrong path. Include as much information as you can about what you ultimately are trying to achieve. See more on this here: https://xyproblem.info/

Icon base by Delapouite under CC BY 3.0 with modifications to add a gradient

go to feed...