ecmascrip?

This commit is contained in:
Ben Harris 2018-03-05 15:09:52 -05:00
parent 04d8892d22
commit 6864077c0a
9 changed files with 6556 additions and 0 deletions

9
ecmascript/.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
*.swp
.DS_Store
npm-debug.log
tmp
bin/configlet
bin/configlet.exe
node_modules
.idea
babel-output

View File

@ -0,0 +1,51 @@
# Hello World
The classical introductory exercise. Just say "Hello, World!".
["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is
the traditional first program for beginning programming in a new language
or environment.
The objectives are simple:
- Write a function that returns the string "Hello, World!".
- Run the test suite and make sure that it succeeds.
- Submit your solution and check it at the website.
If everything goes well, you will be ready to fetch your first real exercise.
## Setup
Go through the setup instructions for ECMAScript to
install the necessary dependencies:
http://exercism.io/languages/ecmascript/installation
## Requirements
Install assignment dependencies:
```bash
$ npm install
```
## Making the test suite pass
Execute the tests with:
```bash
$ npm test
```
In the test suites all tests but the first have been skipped.
Once you get a test passing, you can enable the next one by
changing `xtest` to `test`.
## Source
This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program)
## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

View File

@ -0,0 +1,7 @@
class HelloWorld {
hello() {
return "Hello, World!"
}
}
export default HelloWorld;

View File

@ -0,0 +1,9 @@
import HelloWorld from './hello-world';
describe('Hello World', () => {
const greeter = new HelloWorld();
test('says hello', () => {
expect(greeter.hello()).toEqual('Hello, World!');
});
});

6248
ecmascript/hello-world/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,76 @@
{
"name": "xecmascript",
"version": "0.0.0",
"description": "Exercism exercises in ECMAScript 6.",
"author": "Katrina Owen",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/exercism/xecmascript"
},
"devDependencies": {
"babel-jest": "^21.2.0",
"babel-plugin-transform-builtin-extend": "^1.1.2",
"babel-preset-env": "^1.4.0",
"eslint": "^3.19.0",
"eslint-config-airbnb": "^15.0.1",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^5.0.1",
"eslint-plugin-react": "^7.0.1",
"jest": "^21.2.1"
},
"jest": {
"modulePathIgnorePatterns": [
"package.json"
]
},
"babel": {
"presets": [
[
"env",
{
"node": "current"
}
]
],
"plugins": [
[
"babel-plugin-transform-builtin-extend",
{
"globals": [
"Error"
]
}
],
[
"transform-regenerator"
]
]
},
"scripts": {
"test": "jest --no-cache ./*",
"watch": "jest --no-cache --watch ./*",
"lint": "eslint .",
"lint-test": "eslint . && jest --no-cache ./* "
},
"eslintConfig": {
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"env": {
"es6": true,
"node": true,
"jest": true
},
"extends": "airbnb",
"rules": {
"import/no-unresolved": "off",
"import/extensions": "off"
}
},
"licenses": [
"MIT"
],
"dependencies": {}
}

63
ecmascript/leap/README.md Normal file
View File

@ -0,0 +1,63 @@
# Leap
Given a year, report if it is a leap year.
The tricky thing here is that a leap year in the Gregorian calendar occurs:
```plain
on every year that is evenly divisible by 4
except every year that is evenly divisible by 100
unless the year is also evenly divisible by 400
```
For example, 1997 is not a leap year, but 1996 is. 1900 is not a leap
year, but 2000 is.
If your language provides a method in the standard library that does
this look-up, pretend it doesn't exist and implement it yourself.
## Notes
Though our exercise adopts some very simple rules, there is more to
learn!
For a delightful, four minute explanation of the whole leap year
phenomenon, go watch [this youtube video][video].
[video]: http://www.youtube.com/watch?v=xX96xng7sAE
## Setup
Go through the setup instructions for ECMAScript to
install the necessary dependencies:
http://exercism.io/languages/ecmascript/installation
## Requirements
Install assignment dependencies:
```bash
$ npm install
```
## Making the test suite pass
Execute the tests with:
```bash
$ npm test
```
In the test suites all tests but the first have been skipped.
Once you get a test passing, you can enable the next one by
changing `xtest` to `test`.
## Source
JavaRanch Cattle Drive, exercise 3 [http://www.javaranch.com/leap.jsp](http://www.javaranch.com/leap.jsp)
## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

View File

@ -0,0 +1,23 @@
import Year from './leap';
describe('A leap year', () => {
test('year not divisible by 4: common year', () => {
const year = new Year(2015);
expect(year.isLeap()).toBeFalsy();
});
xtest('year divisible by 4, not divisible by 100: leap year', () => {
const year = new Year(2016);
expect(year.isLeap()).toBeTruthy();
});
xtest('year divisible by 100, not divisible by 400: common year', () => {
const year = new Year(2100);
expect(year.isLeap()).toBeFalsy();
});
xtest('year divisible by 400: leap year', () => {
const year = new Year(2000);
expect(year.isLeap()).toBeTruthy();
});
});

View File

@ -0,0 +1,70 @@
{
"name": "xecmascript",
"version": "0.0.0",
"description": "Exercism exercises in ECMAScript 6.",
"author": "Katrina Owen",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/exercism/xecmascript"
},
"devDependencies": {
"babel-jest": "^21.2.0",
"babel-plugin-transform-builtin-extend": "^1.1.2",
"babel-preset-env": "^1.4.0",
"eslint": "^3.19.0",
"eslint-config-airbnb": "^15.0.1",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^5.0.1",
"eslint-plugin-react": "^7.0.1",
"jest": "^21.2.1"
},
"jest": {
"modulePathIgnorePatterns": [
"package.json"
]
},
"babel": {
"presets": [["env",{"node": "current"}]
],
"plugins": [
[
"babel-plugin-transform-builtin-extend",
{
"globals": [
"Error"
]
}
],
[
"transform-regenerator"
]
]
},
"scripts": {
"test": "jest --no-cache ./*",
"watch": "jest --no-cache --watch ./*",
"lint": "eslint .",
"lint-test": "eslint . && jest --no-cache ./* "
},
"eslintConfig": {
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"env": {
"es6": true,
"node": true,
"jest": true
},
"extends": "airbnb",
"rules": {
"import/no-unresolved": "off",
"import/extensions": "off"
}
},
"licenses": [
"MIT"
],
"dependencies": {}
}