Skip to content

Commit

Permalink
linesegment math operator
Browse files Browse the repository at this point in the history
  • Loading branch information
dqnykamp committed Feb 28, 2023
1 parent 5b2fcd4 commit d0273f6
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 12 deletions.
105 changes: 101 additions & 4 deletions cypress/e2e/DoenetML/equality/mathexpressions.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('Math expressions equality tests', function () {
cy.get('#\\/_text1').should('contain.text', 'a')


let nTrues = 6, nFalses = 2;
let nTrues = 9, nFalses = 3;
for (let i = 1; i <= nTrues; i++) {
cy.get(`#\\/t${i}`).should('have.text', "true")
}
Expand Down Expand Up @@ -266,10 +266,12 @@ describe('Math expressions equality tests', function () {
<boolean name="t5"><math>angle ABC</math> = <math>angle(A,B,C)</math></boolean>
<boolean name="t6">angle A'B'C' = angle(A',B',C')</boolean>
<boolean name="t7">angle A B C = angle(A,B,C)</boolean>
<boolean name="t8" symbolicEquality>angle ABC = angle CBA</boolean>
<boolean name="t9" symbolicEquality>angle(A,B,C) = angle(C,B,A)</boolean>
</p>
<p>
<boolean name="f1">angle ABC = angle ACB></boolean>
<boolean name="f1">angle ABC = angle ACB</boolean>
<boolean name="f2">angle ABC = angle A'B'C'</boolean>
<boolean name="f3">angle(A,B,C) = angle (A,C,B)</boolean>
<boolean name="f4">angle(A,B,C) = angle (A',B',C')</boolean>
Expand All @@ -282,7 +284,7 @@ describe('Math expressions equality tests', function () {



let nTrues = 7, nFalses = 2;
let nTrues = 9, nFalses = 4;

for (let i = 1; i <= nTrues; i++) {
cy.get(`#\\/t${i}`).should('have.text', "true")
Expand Down Expand Up @@ -359,7 +361,7 @@ describe('Math expressions equality tests', function () {

})

it('some support for interal', () => {
it('some support for integral', () => {
cy.window().then(async (win) => {
win.postMessage({
doenetML: `
Expand Down Expand Up @@ -408,5 +410,100 @@ describe('Math expressions equality tests', function () {

})

it('vecs', () => {
cy.window().then(async (win) => {
win.postMessage({
doenetML: `
<text>a</text>
<p>
<boolean name="t1">vec(x) = vec x</boolean>
<boolean name="t2">vec(x) + vec(x) = 2vec(x)</boolean>
<boolean name="t3">vec(x)*vec(x)vec(y)/(vec(x)*vec(x)) = vec(y)</boolean>
</p>
<p>
<boolean name="f1">vec(x) = x</boolean>
<boolean name="f2">vec(xy) = vec(x)vec(y)</boolean>
<boolean name="f3">vec(2x) = 2vec(x)</boolean>
</p>
`}, "*");
});

cy.get('#\\/_text1').should('contain.text', 'a')



let nTrues = 3, nFalses = 3;

for (let i = 1; i <= nTrues; i++) {
cy.get(`#\\/t${i}`).should('have.text', "true")
}

for (let i = 1; i <= nFalses; i++) {
cy.get(`#\\/f${i}`).should('have.text', "false")
}

cy.window().then(async (win) => {
let stateVariables = await win.returnAllStateVariables1();
for (let i = 1; i <= nTrues; i++) {
expect(stateVariables[`/t${i}`].stateValues.value).to.be.true
}
for (let i = 1; i <= nFalses; i++) {
expect(stateVariables[`/f${i}`].stateValues.value).to.be.false
}
})

})

it('linesegments', () => {
cy.window().then(async (win) => {
win.postMessage({
doenetML: `
<text>a</text>
<p>
<boolean name="t1">linesegment(A,B) = linesegment(B,A)</boolean>
<boolean name="t2">vec(x) + vec(x) = 2vec(x)</boolean>
<boolean name="t3">vec(x)*vec(x)vec(y)/(vec(x)*vec(x)) = vec(y)</boolean>
<boolean name="t4" symbolicEquality>linesegment(A,B) = linesegment(B,A)</boolean>
</p>
<p>
<boolean name="f1">vec(x) = x</boolean>
<boolean name="f2">vec(xy) = vec(x)vec(y)</boolean>
<boolean name="f3">vec(2x) = 2vec(x)</boolean>
</p>
`}, "*");
});

cy.get('#\\/_text1').should('contain.text', 'a')



let nTrues = 4, nFalses = 3;

for (let i = 1; i <= nTrues; i++) {
cy.get(`#\\/t${i}`).should('have.text', "true")
}

for (let i = 1; i <= nFalses; i++) {
cy.get(`#\\/f${i}`).should('have.text', "false")
}

cy.window().then(async (win) => {
let stateVariables = await win.returnAllStateVariables1();
for (let i = 1; i <= nTrues; i++) {
expect(stateVariables[`/t${i}`].stateValues.value).to.be.true
}
for (let i = 1; i <= nFalses; i++) {
expect(stateVariables[`/f${i}`].stateValues.value).to.be.false
}
})

})


})
23 changes: 23 additions & 0 deletions cypress/e2e/DoenetML/tagSpecific/math.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5716,6 +5716,29 @@ describe('Math Tag Tests', function () {

})

it('line segment', () => {
cy.window().then(async (win) => {
win.postMessage({
doenetML: `
<text>a</text>
<math format="latex">\\overline{AB}</math>
<math>linesegment(A,B)</math>
` }, "*");
});

cy.get('#\\/_text1').should('have.text', 'a'); // to wait until loaded

cy.get("#\\/_math1 .mjx-mrow").eq(0).should('have.text', '¯¯¯¯¯¯¯¯AB')
cy.get("#\\/_math2 .mjx-mrow").eq(0).should('have.text', '¯¯¯¯¯¯¯¯AB')

cy.window().then(async (win) => {
let stateVariables = await win.returnAllStateVariables1();
expect(stateVariables['/_math1'].stateValues.value).eqls(["linesegment", "A", "B"]);
expect(stateVariables['/_math2'].stateValues.value).eqls(["linesegment", "A", "B"]);
});

})

it('perp', () => {
cy.window().then(async (win) => {
win.postMessage({
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"json-stringify-deterministic": "^1.0.1",
"lodash.debounce": "^4.0.8",
"lorem-ipsum": "^2.0.4",
"math-expressions": "^2.0.0-alpha56",
"math-expressions": "^2.0.0-alpha58",
"nanoid": "^3.1.31",
"react": "^17.0.2",
"react-copy-to-clipboard": "^5.0.3",
Expand Down

0 comments on commit d0273f6

Please sign in to comment.