TestCase subclass: #LBZExerciseTest instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'LearnSqueak-Bezier-Tests'! !LBZExerciseTest methodsFor: 'tests'! testTangentEndpoints | model | model := LBZApp new model. self assert: (model tangentAt: 0) = (240@ -750). self assert: (model tangentAt: 1) = (240@750) ! ! !LBZExerciseTest methodsFor: 'tests'! testTangentMidpoint self assert: (LBZApp new model tangentAt: 1/2) = (600@0) ! ! !LBZExerciseTest methodsFor: 'tests'! testTangentDegenerate | model | model := LBZModel new. model setPoints: {10@20. 10@20. 10@20. 10@20}. self assert: (model tangentAt: 1/2) = (0@0) ! ! !LBZExerciseTest methodsFor: 'tests'! testSplitMatchesOriginal | original halves left right | original := LBZApp new model. halves := original splitAt: 1/3. left := LBZModel new. left setPoints: halves first. right := LBZModel new. right setPoints: halves second. 0 to: 100 do: [:i | self assert: (left pointAt: i/100) = (original pointAt: (i/100 * (1/3))). self assert: (right pointAt: i/100) = (original pointAt: (1/3 + (i/100 * (2/3))))] ! ! !LBZExerciseTest methodsFor: 'tests'! testSplitEndpointsAndIsolation | original before halves | original := LBZApp new model. before := original points. halves := original splitAt: 0. self assert: (halves first allSatisfy: [:p | p = before first]). self assert: halves second = before. halves := original splitAt: 1. self assert: halves first = before. self assert: (halves second allSatisfy: [:p | p = before last]). halves first at: 1 put: 0@0. self assert: original points = before ! ! !LBZExerciseTest methodsFor: 'tests'! testSplitJoinsAtChosenPoint | model halves | model := LBZApp new model. halves := model splitAt: 1/2. self assert: halves first last = (300@(185/2)). self assert: halves first last = halves second first ! !