Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
td-git
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CORONA Nikola
td-git
Commits
344ac038
Commit
344ac038
authored
4 weeks ago
by
CORONA Nikola
Browse files
Options
Downloads
Patches
Plain Diff
TD5 Exercice 2 8)
parent
43d8fac2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
TD5 Test/Exercice.test.ts
+13
-4
13 additions, 4 deletions
TD5 Test/Exercice.test.ts
TD5 Test/MesMaths.ts
+17
-0
17 additions, 0 deletions
TD5 Test/MesMaths.ts
with
30 additions
and
4 deletions
TD5 Test/Exercice.test.ts
+
13
−
4
View file @
344ac038
import
{
multAdd
}
from
"
./MesMaths.ts
"
;
import
{
multAdd
,
puissanceMult
}
from
"
./MesMaths.ts
"
;
import
{
assertEquals
}
from
"
jsr:@std/assert/equals
"
;
import
{
assertEquals
}
from
"
jsr:@std/assert/equals
"
;
import
{
assertAlmostEquals
}
from
"
jsr:@std/assert/almost-equals
"
;
import
{
assertAlmostEquals
}
from
"
jsr:@std/assert/almost-equals
"
;
...
@@ -6,11 +6,20 @@ Deno.test("cas général", () => {
...
@@ -6,11 +6,20 @@ Deno.test("cas général", () => {
assertEquals
(
multAdd
(
3
,
8
),
24
);
assertEquals
(
multAdd
(
3
,
8
),
24
);
});
});
Deno
.
test
(
"
multiplication par 0
"
,
()
=>
{
Deno
.
test
(
"
multiplication par 0
"
,
()
=>
{
assertEquals
(
multAdd
(
3
,
0
),
0
);
assertEquals
(
multAdd
(
3
,
0
),
0
);
});
});
Deno
.
test
(
"
multiplication par un nombre négatif
"
,
()
=>
{
Deno
.
test
(
"
multiplication par un nombre négatif
"
,
()
=>
{
assertEquals
(
multAdd
(
3
,
-
8
),
-
24
);
assertEquals
(
multAdd
(
3
,
-
8
),
-
24
);
});
});
Deno
.
test
(
"
multiplication par 2 nombre négatif
"
,
()
=>
{
Deno
.
test
(
"
multiplication par 2 nombre négatif
"
,
()
=>
{
assertEquals
(
multAdd
(
-
8
,
-
8
),
64
);
assertEquals
(
multAdd
(
-
8
,
-
8
),
64
);
});
});
Deno
.
test
(
"
Puissance par un nombre négatif
"
,
()
=>
{
assertEquals
(
puissanceMult
(
-
5
,
9
),
-
1953125
);
});
Deno
.
test
(
"
Puissance par un nombre négatif
"
,
()
=>
{
assertEquals
(
puissanceMult
(
5
,
-
9
),
-
1953125
);
});
This diff is collapsed.
Click to expand it.
TD5 Test/MesMaths.ts
+
17
−
0
View file @
344ac038
...
@@ -13,3 +13,20 @@ export function multAdd(x: number, y: number): number {
...
@@ -13,3 +13,20 @@ export function multAdd(x: number, y: number): number {
else
return
resultat
;
else
return
resultat
;
}
}
export
function
puissanceMult
(
x
:
number
,
y
:
number
):
number
{
let
val
=
1
;
let
inf
=
0
;
if
(
y
<
0
){
y
=
-
y
inf
=
1
;
}
for
(
let
i
=
0
;
i
<
y
;
i
++
)
{
val
*=
x
;
}
if
(
inf
===
1
)
return
-
val
;
else
return
val
;
}
// 1) on doit tester pour y negatif car il renvoit 1
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment