Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Commit

Permalink
Add temporary test for language features
Browse files Browse the repository at this point in the history
  • Loading branch information
vweevers committed Apr 8, 2021
1 parent 2497994 commit 1b7455a
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .airtap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ providers:
browsers:
- name: chrome
- name: firefox
- name: safari
version: 11
platform: Mac 10.13 # https://github.com/airtap/sauce-browsers/issues/3
# - name: safari
# version: 11
# platform: Mac 10.13 # https://github.com/airtap/sauce-browsers/issues/3
- name: safari
version: 12..latest
- name: ios_saf
version: 11..latest
version: 12..latest
- name: chrome for android
version: 6..latest
- name: msedge
Expand Down
70 changes: 70 additions & 0 deletions test/self.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,76 @@ function implement (ctor, methods) {
return Test
}

// Temporary test for browsers
test('language features', function (t) {
const { foo } = { foo: 1 }
t.is(foo, 1)

// Rest/Spread Properties. Not on Safari < 11.1 (2018-04-12, 0.43%), Safari iOS < 11.3 (2018-03-29, 0.69%)
// https://github.com/tc39/proposal-object-rest-spread
const { a, ...rest } = { a: 1, b: 2, c: 3 }
t.is(a, 1)
t.same(Object.keys(rest), ['b', 'c'])

// Spread in object literals
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax#spread_in_object_literals
t.same({ ...rest, c: 100 }, { b: 2, c: 100 }) // Not on Safari iOS < 11.3 (2018-03-29, 0.69%)

;((...rest) => t.same(rest, [1, 2, 3]))(1, 2, 3)

const x = 9
for (const x of [10]) t.is(x, 10)
{ const x = 11; t.is(x, 11) }
t.is(x, 9)

t.is(`foo ${88}`, 'foo 88')

class Test {}
t.is(typeof Test, 'function')
t.is(typeof global.Map, 'function', 'map')
t.is(typeof global.Set, 'function', 'set')
t.is(typeof String.prototype.startsWith, 'function', 'String#startsWith')
t.is(typeof String.prototype.includes, 'function', 'String#includes')
t.is(typeof Array.from, 'function', 'Array.from()')
t.is(typeof Number.isInteger, 'function', 'Number.isInteger')

const kA = Symbol('a')
const kB = Symbol('b')
const obj = { [kA]: true, [kB]: false }
t.is(obj[kA], true)
t.is(obj[kB], false)
t.is(typeof Symbol.for, 'function', 'global symbol registry')

new Promise((resolve) => resolve(123)).then((res) => {
t.is(res, 123)
t.end()
})
})

// Not on Safari < 12 (0.5%, 2018-09-17) and Safari iOS < 12 (0.78%, 2018-09-17)
test('async generator', async function (t) {
let ended = false

async function * generator () {
try {
yield 1
yield 2
yield 3
} finally {
ended = true
}
}

const res = []

for await (const x of generator()) {
res.push(x)
}

t.same(res, [1, 2, 3])
t.is(ended, true)
})

/**
* Extensibility
*/
Expand Down

0 comments on commit 1b7455a

Please sign in to comment.