11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciif ((!common.hasCrypto) || (!common.hasIntl)) {
41cb0ef41Sopenharmony_ci  common.skip('ESLint tests require crypto and Intl');
51cb0ef41Sopenharmony_ci}
61cb0ef41Sopenharmony_cicommon.skipIfEslintMissing();
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciconst RuleTester = require('../../tools/node_modules/eslint').RuleTester;
91cb0ef41Sopenharmony_ciconst rule = require('../../tools/eslint-rules/async-iife-no-unused-result');
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciconst message = 'The result of an immediately-invoked async function needs ' +
121cb0ef41Sopenharmony_ci  'to be used (e.g. with `.then(common.mustCall())`)';
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ciconst tester = new RuleTester({ parserOptions: { ecmaVersion: 8 } });
151cb0ef41Sopenharmony_citester.run('async-iife-no-unused-result', rule, {
161cb0ef41Sopenharmony_ci  valid: [
171cb0ef41Sopenharmony_ci    '(() => {})()',
181cb0ef41Sopenharmony_ci    '(async () => {})',
191cb0ef41Sopenharmony_ci    '(async () => {})().then()',
201cb0ef41Sopenharmony_ci    '(async () => {})().catch()',
211cb0ef41Sopenharmony_ci    '(function () {})()',
221cb0ef41Sopenharmony_ci    '(async function () {})',
231cb0ef41Sopenharmony_ci    '(async function () {})().then()',
241cb0ef41Sopenharmony_ci    '(async function () {})().catch()',
251cb0ef41Sopenharmony_ci  ],
261cb0ef41Sopenharmony_ci  invalid: [
271cb0ef41Sopenharmony_ci    {
281cb0ef41Sopenharmony_ci      code: '(async () => {})()',
291cb0ef41Sopenharmony_ci      errors: [{ message }],
301cb0ef41Sopenharmony_ci      output: '(async () => {})()',
311cb0ef41Sopenharmony_ci    },
321cb0ef41Sopenharmony_ci    {
331cb0ef41Sopenharmony_ci      code: '(async function() {})()',
341cb0ef41Sopenharmony_ci      errors: [{ message }],
351cb0ef41Sopenharmony_ci      output: '(async function() {})()',
361cb0ef41Sopenharmony_ci    },
371cb0ef41Sopenharmony_ci    {
381cb0ef41Sopenharmony_ci      code: "const common = require('../common');(async () => {})()",
391cb0ef41Sopenharmony_ci      errors: [{ message }],
401cb0ef41Sopenharmony_ci      output: "const common = require('../common');(async () => {})()" +
411cb0ef41Sopenharmony_ci        '.then(common.mustCall())',
421cb0ef41Sopenharmony_ci    },
431cb0ef41Sopenharmony_ci    {
441cb0ef41Sopenharmony_ci      code: "const common = require('../common');(async function() {})()",
451cb0ef41Sopenharmony_ci      errors: [{ message }],
461cb0ef41Sopenharmony_ci      output: "const common = require('../common');(async function() {})()" +
471cb0ef41Sopenharmony_ci        '.then(common.mustCall())',
481cb0ef41Sopenharmony_ci    },
491cb0ef41Sopenharmony_ci  ]
501cb0ef41Sopenharmony_ci});
51