trackler 2.0.8.28 → 2.0.8.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/common/CONTRIBUTING.md +4 -1
- data/common/README.md +52 -0
- data/lib/trackler/version.rb +1 -1
- data/tracks/ecmascript/config.json +7 -0
- data/tracks/ecmascript/exercises/perfect-numbers/example.js +68 -0
- data/tracks/ecmascript/exercises/perfect-numbers/gulpfile.js +89 -0
- data/tracks/ecmascript/exercises/perfect-numbers/package.json +28 -0
- data/tracks/ecmascript/exercises/perfect-numbers/perfect-numbers.spec.js +75 -0
- data/tracks/erlang/exercises/accumulate/src/accumulate.app.src +1 -1
- data/tracks/erlang/exercises/all-your-base/src/all_your_base.app.src +1 -1
- data/tracks/erlang/exercises/allergies/src/allergies.app.src +1 -1
- data/tracks/erlang/exercises/anagram/src/anagram.app.src +1 -1
- data/tracks/erlang/exercises/atbash-cipher/src/atbash_cipher.app.src +1 -1
- data/tracks/erlang/exercises/bank-account/src/bank_account.app.src +1 -1
- data/tracks/erlang/exercises/beer-song/src/beer_song.app.src +1 -1
- data/tracks/erlang/exercises/bob/src/bob.app.src +1 -1
- data/tracks/erlang/exercises/circular-buffer/src/circular_buffer.app.src +1 -1
- data/tracks/erlang/exercises/clock/src/clock.app.src +1 -1
- data/tracks/erlang/exercises/difference-of-squares/src/difference_of_squares.app.src +1 -1
- data/tracks/erlang/exercises/etl/src/etl.app.src +1 -1
- data/tracks/erlang/exercises/gigasecond/src/gigasecond.app.src +1 -1
- data/tracks/erlang/exercises/grade-school/src/grade_school.app.src +1 -1
- data/tracks/erlang/exercises/grains/src/grains.app.src +1 -1
- data/tracks/erlang/exercises/hamming/src/hamming.app.src +1 -1
- data/tracks/erlang/exercises/hello-world/src/hello_world.app.src +1 -1
- data/tracks/erlang/exercises/largest-series-product/src/largest_series_product.app.src +1 -1
- data/tracks/erlang/exercises/leap/src/leap.app.src +1 -1
- data/tracks/erlang/exercises/luhn/src/luhn.app.src +1 -1
- data/tracks/erlang/exercises/meetup/src/meetup.app.src +1 -1
- data/tracks/erlang/exercises/nucleotide-count/src/nucleotide_count.app.src +1 -1
- data/tracks/erlang/exercises/parallel-letter-frequency/src/parallel_letter_frequency.app.src +1 -1
- data/tracks/erlang/exercises/phone-number/src/phone_number.app.src +1 -1
- data/tracks/erlang/exercises/rna-transcription/src/rna_transcription.app.src +1 -1
- data/tracks/erlang/exercises/robot-simulator/src/robot_simulator.app.src +1 -1
- data/tracks/erlang/exercises/roman-numerals/src/roman_numerals.app.src +1 -1
- data/tracks/erlang/exercises/rotational-cipher/src/rotational_cipher.app.src +1 -1
- data/tracks/erlang/exercises/scrabble-score/src/scrabble_score.app.src +1 -1
- data/tracks/erlang/exercises/series/src/series.app.src +1 -1
- data/tracks/erlang/exercises/space-age/src/space_age.app.src +1 -1
- data/tracks/erlang/exercises/strain/src/strain.app.src +1 -1
- data/tracks/erlang/exercises/sum-of-multiples/src/sum_of_multiples.app.src +1 -1
- data/tracks/erlang/exercises/triangle/src/triangle.app.src +1 -1
- data/tracks/erlang/exercises/word-count/src/word_count.app.src +1 -1
- data/tracks/erlang/exercises/zipper/src/zipper.app.src +1 -1
- data/tracks/go/exercises/hello-world/hello_world.go +10 -1
- data/tracks/haskell/exercises/simple-linked-list/examples/success-standard/package.yaml +1 -0
- data/tracks/haskell/exercises/simple-linked-list/examples/success-standard/src/LinkedList.hs +1 -0
- data/tracks/haskell/exercises/simple-linked-list/package.yaml +1 -0
- data/tracks/haskell/exercises/simple-linked-list/src/LinkedList.hs +1 -1
- data/tracks/haskell/exercises/simple-linked-list/test/Tests.hs +37 -1
- data/tracks/java/exercises/diamond/src/test/java/DiamondPrinterTest.java +13 -6
- data/tracks/java/exercises/secret-handshake/src/test/java/HandshakeCalculatorTest.java +21 -13
- data/tracks/objective-c/exercises/atbash-cipher/AtbashCipherExample.m +1 -1
- data/tracks/objective-c/exercises/beer-song/BeerSongExample.m +1 -1
- data/tracks/objective-c/exercises/beer-song/BeerSongTest.m +4 -4
- data/tracks/objective-c/exercises/binary-search/BinarySearchExample.m +1 -1
- data/tracks/objective-c/exercises/flatten-array/FlattenArrayExample.h +2 -1
- data/tracks/objective-c/exercises/flatten-array/FlattenArrayExample.m +12 -25
- data/tracks/objective-c/exercises/flatten-array/FlattenArrayTest.m +32 -80
- data/tracks/objective-c/exercises/sublist/SublistTest.m +47 -70
- data/tracks/perl6/exercises/allergies/Allergies.pm6 +1 -0
- data/tracks/perl6/exercises/allergies/Example.pm +3 -1
- data/tracks/perl6/exercises/allergies/allergies.t +187 -137
- data/tracks/perl6/exercises/anagram/Anagram.pm6 +1 -0
- data/tracks/perl6/exercises/anagram/Example.pm +15 -15
- data/tracks/perl6/exercises/anagram/anagram.t +164 -15
- data/tracks/perl6/exercises/atbash-cipher/AtbashCipher.pm6 +1 -0
- data/tracks/perl6/exercises/atbash-cipher/Example.pm +2 -0
- data/tracks/perl6/exercises/atbash-cipher/atbash-cipher.t +109 -86
- data/tracks/perl6/exercises/grains/Example.pm +10 -9
- data/tracks/perl6/exercises/grains/Grains.pm6 +1 -0
- data/tracks/perl6/exercises/grains/grains.t +126 -18
- data/tracks/perl6/exercises/leap/Example.pm +9 -9
- data/tracks/perl6/exercises/leap/Leap.pm6 +4 -0
- data/tracks/perl6/exercises/leap/leap.t +61 -17
- data/tracks/perl6/exercises/phone-number/Example.pm +4 -28
- data/tracks/perl6/exercises/phone-number/PhoneNumber.pm6 +4 -0
- data/tracks/perl6/exercises/phone-number/phone-number.t +102 -65
- data/tracks/perl6/exercises/raindrops/Example.pm +10 -8
- data/tracks/perl6/exercises/raindrops/Raindrops.pm6 +4 -0
- data/tracks/perl6/exercises/raindrops/raindrops.t +153 -20
- data/tracks/perl6/exercises/rna-transcription/Example.pm +5 -7
- data/tracks/perl6/exercises/rna-transcription/RNA.pm6 +4 -0
- data/tracks/perl6/exercises/rna-transcription/rna-transcription.t +107 -11
- data/tracks/perl6/exercises/scrabble-score/Example.pm +14 -19
- data/tracks/perl6/exercises/scrabble-score/Scrabble.pm6 +4 -0
- data/tracks/perl6/exercises/scrabble-score/scrabble-score.t +106 -15
- data/tracks/perl6/exercises/space-age/Example.pm +29 -13
- data/tracks/perl6/exercises/space-age/SpaceAge.pm6 +22 -0
- data/tracks/perl6/exercises/space-age/space-age.t +90 -52
- data/tracks/perl6/exercises/word-count/Example.pm +4 -8
- data/tracks/perl6/exercises/word-count/WordCount.pm6 +4 -0
- data/tracks/perl6/exercises/word-count/word-count.t +149 -16
- data/tracks/perl6/exercises/wordy/Example.pm +13 -13
- data/tracks/perl6/exercises/wordy/Wordy.pm6 +4 -0
- data/tracks/perl6/exercises/wordy/wordy.t +140 -97
- data/tracks/purescript/config.json +7 -0
- data/tracks/purescript/exercises/atbash-cipher/bower.json +18 -0
- data/tracks/purescript/exercises/atbash-cipher/examples/src/AtbashCipher.purs +41 -0
- data/tracks/purescript/exercises/atbash-cipher/src/AtbashCipher.purs +4 -0
- data/tracks/purescript/exercises/atbash-cipher/test/Main.purs +64 -0
- data/tracks/python/exercises/run-length-encoding/run_length_encoding_test.py +2 -0
- data/tracks/swift/exercises/grade-school/Tests/GradeSchoolTests/GradeSchoolTests.swift +1 -1
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e21f79cd25d4f3e7897f3fba2b92b97d5421c2c
|
4
|
+
data.tar.gz: 5d736d15895b6996ba58b26507cb0d25235977bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94d0844a039d14c39e3da56990983b777c1cecf1a6c1473a3fa64f1b36ccf8ad35afbd5319446b3bd5d3fe13591d74fa6c23bb2ced918f7c0605e2d09bb8d62c
|
7
|
+
data.tar.gz: b86d66e2f9a4ef93b28fe065e69b2e143867bffc3b3fd290712ae1bf22725f83d69697e636475300879f47724e125e0e86d16e82ad03f3cb2397941dd651713f
|
data/common/CONTRIBUTING.md
CHANGED
@@ -198,7 +198,10 @@ needs to be made in the [exercism/x-common repository](https://github.com/exerci
|
|
198
198
|
not directly to the test suite itself.
|
199
199
|
|
200
200
|
Find the JSON file for the problem in question. For example, if you want to change
|
201
|
-
the Clock problem, then look for `exercises/clock/canonical-data.json`.
|
201
|
+
the Clock problem, then look for `exercises/clock/canonical-data.json`. Each
|
202
|
+
change should also bump the version of the test data. For more information,
|
203
|
+
see the [test data versioning](README.md#test-data-versioning) section of the
|
204
|
+
README.
|
202
205
|
|
203
206
|
Submit a pull request with the change.
|
204
207
|
|
data/common/README.md
CHANGED
@@ -111,6 +111,58 @@ There are also some convention about `expected` that you must follow:
|
|
111
111
|
- The string should explain why the error would occur.
|
112
112
|
- A particular track's implementation of the exercise **need not** necessarily check that the error includes that exact string as the cause, depending on what is idiomatic in the language (it may not be idiomatic to check strings for error messages).
|
113
113
|
|
114
|
+
### Test Data Versioning
|
115
|
+
|
116
|
+
Test data should be versioned according to [Semantic Version 2.0](http://semver.org/), which is defined as follows:
|
117
|
+
|
118
|
+
> Given a version number MAJOR.MINOR.PATCH, increment the:
|
119
|
+
>
|
120
|
+
> MAJOR version when you make incompatible API changes,
|
121
|
+
> MINOR version when you add functionality in a backwards-compatible manner, and
|
122
|
+
> PATCH version when you make backwards-compatible bug fixes.
|
123
|
+
> Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
|
124
|
+
|
125
|
+
#### MAJOR version changes
|
126
|
+
|
127
|
+
The MAJOR version should be changed when the test suite is modified in a
|
128
|
+
fundamentally incompatible way.
|
129
|
+
|
130
|
+
There are examples of changes requiring a MAJOR version change:
|
131
|
+
|
132
|
+
- A new "property" (test type).
|
133
|
+
- Renaming a "property".
|
134
|
+
- Insertion, deletion or renaming of keys in the test data object.
|
135
|
+
- Changing the type of one of the test data keys.
|
136
|
+
|
137
|
+
MAJOR changes should be expected to break even well-behaved test generators.
|
138
|
+
|
139
|
+
#### MINOR version changes
|
140
|
+
|
141
|
+
The MINOR version should change when you add functionality in a backwards-compatible manner, make
|
142
|
+
non-breaking changes that alter the meaning of the test suite, make previously
|
143
|
+
passing solutions possibly fail, or failing solutions fail at a different spot.
|
144
|
+
|
145
|
+
There are examples of changes requiring a MINOR version change:
|
146
|
+
|
147
|
+
- Adding or deleting test cases.
|
148
|
+
- Changing the test cases inputs and/or outputs.
|
149
|
+
- Changing the test cases ordering.
|
150
|
+
|
151
|
+
MINOR changes would never break well-designed test generators, because the test-generation logic remains exactly the same.
|
152
|
+
|
153
|
+
#### PATCH version changes
|
154
|
+
|
155
|
+
The PATCH version should change when you make backwards-compatible bug fixes or
|
156
|
+
whenever the meaning of the tests does not change.
|
157
|
+
|
158
|
+
There are examples of changes requiring a PATCH version change:
|
159
|
+
|
160
|
+
- Regrouping/"Renesting" test cases without changing test case ordering.
|
161
|
+
- Changing descriptions or comments.
|
162
|
+
- Changing keys' ordering or formatting (would result in an equivalent JSON file).
|
163
|
+
|
164
|
+
PATCH changes would never break well-designed test generators, because the test data remains exactly the same.
|
165
|
+
|
114
166
|
## Automated Tests
|
115
167
|
|
116
168
|
`canonical-data.json` for each exercise is checked for compliancy against the [canonical-schema.json](canonical-schema.json).
|
data/lib/trackler/version.rb
CHANGED
@@ -11,6 +11,7 @@
|
|
11
11
|
"rna-transcription",
|
12
12
|
"bob",
|
13
13
|
"gigasecond",
|
14
|
+
"perfect-numbers",
|
14
15
|
"word-count",
|
15
16
|
"pangram",
|
16
17
|
"beer-song",
|
@@ -103,6 +104,12 @@
|
|
103
104
|
"difficulty": 1,
|
104
105
|
"topics": [
|
105
106
|
]
|
107
|
+
},
|
108
|
+
{
|
109
|
+
"slug": "perfect-numbers",
|
110
|
+
"difficulty": 1,
|
111
|
+
"topics": [
|
112
|
+
]
|
106
113
|
},
|
107
114
|
{
|
108
115
|
"slug": "word-count",
|
@@ -0,0 +1,68 @@
|
|
1
|
+
|
2
|
+
export default class PerfectNumbers {
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Calculate all the divisors for a given number.
|
6
|
+
* @param {number} number - natural number.
|
7
|
+
* @returns {array} array that contains the divisors for a given number NOT including the number itself.
|
8
|
+
*/
|
9
|
+
getDivisors(number) {
|
10
|
+
|
11
|
+
let i;
|
12
|
+
let divs = new Array();
|
13
|
+
|
14
|
+
// Accepts only natural numbers greater than 1.
|
15
|
+
if (number <= 1) {
|
16
|
+
return divs;
|
17
|
+
}
|
18
|
+
|
19
|
+
// 1 always divides everyone!
|
20
|
+
divs.push(1);
|
21
|
+
|
22
|
+
// Calculate the divisors up the the half of the number + 1
|
23
|
+
for (i = 2; i <= number / 2; i++) {
|
24
|
+
|
25
|
+
if (number % i === 0) {
|
26
|
+
divs.push(i);
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
return divs;
|
31
|
+
}
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Classify a given number as perfect, abundant or deficient.
|
35
|
+
* @param {number} number - number to be classified. Note: if the number is equal or smaller than 0,
|
36
|
+
* then returns an error: Classification is only possible for natural numbers.
|
37
|
+
* @returns {string} - string that contains the number classification (perfect, abundant or deficient).
|
38
|
+
*/
|
39
|
+
classify(number) {
|
40
|
+
|
41
|
+
let i, sum, result;
|
42
|
+
|
43
|
+
// Check if the input is valid
|
44
|
+
if (number <= 0) {
|
45
|
+
return 'Classification is only possible for natural numbers.';
|
46
|
+
}
|
47
|
+
|
48
|
+
// Factorize the current number.
|
49
|
+
const divsArray = this.getDivisors(number);
|
50
|
+
|
51
|
+
// Sum the factors.
|
52
|
+
sum = divsArray.reduce((sum, div) => sum += div, 0);
|
53
|
+
|
54
|
+
// Check if the number is perfect.
|
55
|
+
if (sum === number) {
|
56
|
+
result = 'perfect';
|
57
|
+
}
|
58
|
+
else if (sum > number) {
|
59
|
+
result = 'abundant';
|
60
|
+
}
|
61
|
+
else {
|
62
|
+
result = 'deficient';
|
63
|
+
}
|
64
|
+
|
65
|
+
return result;
|
66
|
+
}
|
67
|
+
|
68
|
+
}
|
@@ -0,0 +1,89 @@
|
|
1
|
+
function getInputDirectory(argv) {
|
2
|
+
if (argv.input) {
|
3
|
+
return argv.input;
|
4
|
+
}
|
5
|
+
return '.';
|
6
|
+
}
|
7
|
+
|
8
|
+
function getOutputDirectory(argv) {
|
9
|
+
if (argv.output) {
|
10
|
+
return argv.output;
|
11
|
+
}
|
12
|
+
return 'babel-output';
|
13
|
+
}
|
14
|
+
|
15
|
+
const gulp = require('gulp'),
|
16
|
+
eslint = require('gulp-eslint'),
|
17
|
+
jasmine = require('gulp-jasmine'),
|
18
|
+
babel = require('gulp-babel'),
|
19
|
+
polyfill = require('babel/polyfill'),
|
20
|
+
del = require('del'),
|
21
|
+
argv = require('yargs').argv,
|
22
|
+
inputDir = getInputDirectory(argv),
|
23
|
+
outputDir = getOutputDirectory(argv);
|
24
|
+
|
25
|
+
// Gulp tasks definition
|
26
|
+
|
27
|
+
gulp.task('default', [ 'test' ]);
|
28
|
+
|
29
|
+
gulp.task('test', [ 'babel' ], function () {
|
30
|
+
return gulp.src([ outputDir + '/*.spec.js' ])
|
31
|
+
.pipe(jasmine());
|
32
|
+
});
|
33
|
+
|
34
|
+
gulp.task('babel', function () {
|
35
|
+
return gulp.src([ inputDir + '/*.js', inputDir + '/lib/*.js' ])
|
36
|
+
.pipe(babel())
|
37
|
+
.pipe(gulp.dest(outputDir));
|
38
|
+
});
|
39
|
+
|
40
|
+
gulp.task('lint', function () {
|
41
|
+
return gulp.src([ inputDir + '/*.js' ])
|
42
|
+
.pipe(eslint({
|
43
|
+
envs: [
|
44
|
+
'es6' //turns on all es6 features except modules
|
45
|
+
],
|
46
|
+
rules: {
|
47
|
+
// full documentation here : http://eslint.org/docs/rules
|
48
|
+
|
49
|
+
// Possible errors
|
50
|
+
'comma-dangle': [2, 'never'], // don't let a comma at the end of object properties or array element
|
51
|
+
'no-cond-assign': [2, 'always'], // no assignments in conditional statements
|
52
|
+
'no-console': 2, // no console.log() statements in production code
|
53
|
+
'no-constant-condition': 2, // no constants in conditional statements
|
54
|
+
'no-control-regex': 2, // no control characters in regex's
|
55
|
+
'no-debugger': 2, // no debugger in productin code
|
56
|
+
'no-dupe-args': 2, // no duplicated arguments in functions
|
57
|
+
'no-dupe-keys': 2, // no duplicated keys when creating object literals
|
58
|
+
'no-duplicate-case': 2, // no duplicated `case` in `switch` statements
|
59
|
+
'no-empty-character-class': 2, // disallow the use of empty character classes in regular expressions
|
60
|
+
'no-empty': 2, // no empty blocks
|
61
|
+
'no-ex-assign': 2, // do not assign any value to an Exception raised
|
62
|
+
'no-extra-boolean-cast': 2, // do not use !!falseExpression to cast to boolean
|
63
|
+
'no-extra-parens': 2, // do not use extra parenthesis
|
64
|
+
'no-extra-semi': 2, // do not use extra semicolons
|
65
|
+
'no-func-assign': 2, // do not overwrite variables declared as functions
|
66
|
+
'no-inner-declarations': [2, 'both'], // only declare var's and funct's on function scope
|
67
|
+
'no-invalid-regexp': 2, // validates string arguments passed to RegExp constructor
|
68
|
+
'no-irregular-whitespace': 2, // detects special characters used as spaces
|
69
|
+
'no-negated-in-lhs': 2, // do not use negation in the left operand in an `in` expression
|
70
|
+
'no-obj-calls': 2, // prevent calling global objects as if they were functions
|
71
|
+
'no-regex-spaces': 2, // do not use multiple spaces in regex's
|
72
|
+
'no-sparse-arrays': 2, // do not use sparse arrays (empty elements)
|
73
|
+
'no-unexpected-multiline': 2, // Avoid code that looks like two expressions but is actually one
|
74
|
+
'no-unreachable': 2, // detects unreachable statements (after return, throw,...)
|
75
|
+
'use-isnan': 2, // do not compare with `NaN` value, use isNan() instead
|
76
|
+
'valid-jsdoc': 2, // ensure JSDoc comments are valid
|
77
|
+
'valid-typeof': 2 // ensure that the results of typeof are compared against a valid string
|
78
|
+
},
|
79
|
+
ecmaFeatures: {
|
80
|
+
'modules': true //this gives us modules :)
|
81
|
+
}
|
82
|
+
}))
|
83
|
+
.pipe(eslint.format())
|
84
|
+
.pipe(eslint.failAfterError());
|
85
|
+
});
|
86
|
+
|
87
|
+
gulp.task('clean', function (cb) {
|
88
|
+
del([ outputDir ], cb);
|
89
|
+
});
|
@@ -0,0 +1,28 @@
|
|
1
|
+
{
|
2
|
+
"name": "xecmascript",
|
3
|
+
"version": "0.0.0",
|
4
|
+
"description": "Exercism exercises in ECMAScript 6.",
|
5
|
+
"author": "Katrina Owen",
|
6
|
+
"private": true,
|
7
|
+
"repository": {
|
8
|
+
"type": "git",
|
9
|
+
"url": "https://github.com/exercism/xecmascript"
|
10
|
+
},
|
11
|
+
"devDependencies": {
|
12
|
+
"babel": "~5.8.29",
|
13
|
+
"del": "~2.0.2",
|
14
|
+
"gulp": "~3.9.0",
|
15
|
+
"gulp-babel": "~5.3.0",
|
16
|
+
"gulp-eslint": "^1.1.0",
|
17
|
+
"gulp-jasmine": "~2.4.2",
|
18
|
+
"yargs": "~3.27.0"
|
19
|
+
},
|
20
|
+
"scripts": {
|
21
|
+
"test": "gulp test",
|
22
|
+
"lint-test": "gulp lint test"
|
23
|
+
},
|
24
|
+
"licenses": [
|
25
|
+
"MIT"
|
26
|
+
],
|
27
|
+
"dependencies": {}
|
28
|
+
}
|
@@ -0,0 +1,75 @@
|
|
1
|
+
import PerfectNumbers from './perfect-numbers';
|
2
|
+
|
3
|
+
describe('Exercise - Perfect Numbers', () => {
|
4
|
+
|
5
|
+
const perfectNumbers = new PerfectNumbers();
|
6
|
+
|
7
|
+
describe('Perfect Numbers', () => {
|
8
|
+
|
9
|
+
it('Smallest perfect number is classified correctly', () => {
|
10
|
+
expect(perfectNumbers.classify(6)).toEqual('perfect');
|
11
|
+
});
|
12
|
+
|
13
|
+
it('Medium perfect number is classified correctly', () => {
|
14
|
+
expect(perfectNumbers.classify(28)).toEqual('perfect');
|
15
|
+
});
|
16
|
+
|
17
|
+
it('Large perfect number is classified correctly', () => {
|
18
|
+
expect(perfectNumbers.classify(33550336)).toEqual('perfect');
|
19
|
+
});
|
20
|
+
|
21
|
+
});
|
22
|
+
|
23
|
+
describe('Abundant Numbers', () => {
|
24
|
+
|
25
|
+
it('Smallest abundant number is classified correctly', () => {
|
26
|
+
expect(perfectNumbers.classify(12)).toEqual('abundant');
|
27
|
+
});
|
28
|
+
|
29
|
+
it('Medium abundant number is classified correctly', () => {
|
30
|
+
expect(perfectNumbers.classify(30)).toEqual('abundant');
|
31
|
+
});
|
32
|
+
|
33
|
+
it('Large abundant number is classified correctly', () => {
|
34
|
+
expect(perfectNumbers.classify(33550335)).toEqual('abundant');
|
35
|
+
});
|
36
|
+
|
37
|
+
});
|
38
|
+
|
39
|
+
describe('Deficient Numbers', () => {
|
40
|
+
|
41
|
+
it('Smallest prime deficient number is classified correctly', () => {
|
42
|
+
expect(perfectNumbers.classify(2)).toEqual('deficient');
|
43
|
+
});
|
44
|
+
|
45
|
+
it('Smallest non-prime deficient number is classified correctly', () => {
|
46
|
+
expect(perfectNumbers.classify(4)).toEqual('deficient');
|
47
|
+
});
|
48
|
+
|
49
|
+
it('Medium deficient number is classified correctly', () => {
|
50
|
+
expect(perfectNumbers.classify(32)).toEqual('deficient');
|
51
|
+
});
|
52
|
+
|
53
|
+
it('Large deficient number is classified correctly', () => {
|
54
|
+
expect(perfectNumbers.classify(33550337)).toEqual('deficient');
|
55
|
+
});
|
56
|
+
|
57
|
+
it('Edge case (no factors other than itself) is classified correctly', () => {
|
58
|
+
expect(perfectNumbers.classify(1)).toEqual('deficient');
|
59
|
+
});
|
60
|
+
|
61
|
+
});
|
62
|
+
|
63
|
+
describe('Invalid Inputs', () => {
|
64
|
+
|
65
|
+
it('Zero is rejected (not a natural number)', () => {
|
66
|
+
expect(perfectNumbers.classify(0)).toEqual('Classification is only possible for natural numbers.');
|
67
|
+
});
|
68
|
+
|
69
|
+
it('Negative integer is rejected (not a natural number)', () => {
|
70
|
+
expect(perfectNumbers.classify(-1)).toEqual('Classification is only possible for natural numbers.');
|
71
|
+
});
|
72
|
+
|
73
|
+
});
|
74
|
+
|
75
|
+
});
|