11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_cirequire('../common');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ciconst { AsyncLocalStorage } = require('async_hooks');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst asyncLocalStorage = new AsyncLocalStorage();
71cb0ef41Sopenharmony_ciconst asyncLocalStorage2 = new AsyncLocalStorage();
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_cisetTimeout(() => {
101cb0ef41Sopenharmony_ci  asyncLocalStorage.run(new Map(), () => {
111cb0ef41Sopenharmony_ci    asyncLocalStorage2.run(new Map(), () => {
121cb0ef41Sopenharmony_ci      const store = asyncLocalStorage.getStore();
131cb0ef41Sopenharmony_ci      const store2 = asyncLocalStorage2.getStore();
141cb0ef41Sopenharmony_ci      store.set('hello', 'world');
151cb0ef41Sopenharmony_ci      store2.set('hello', 'foo');
161cb0ef41Sopenharmony_ci      setTimeout(() => {
171cb0ef41Sopenharmony_ci        assert.strictEqual(asyncLocalStorage.getStore().get('hello'), 'world');
181cb0ef41Sopenharmony_ci        assert.strictEqual(asyncLocalStorage2.getStore().get('hello'), 'foo');
191cb0ef41Sopenharmony_ci        asyncLocalStorage.exit(() => {
201cb0ef41Sopenharmony_ci          assert.strictEqual(asyncLocalStorage.getStore(), undefined);
211cb0ef41Sopenharmony_ci          assert.strictEqual(asyncLocalStorage2.getStore().get('hello'), 'foo');
221cb0ef41Sopenharmony_ci        });
231cb0ef41Sopenharmony_ci        assert.strictEqual(asyncLocalStorage.getStore().get('hello'), 'world');
241cb0ef41Sopenharmony_ci        assert.strictEqual(asyncLocalStorage2.getStore().get('hello'), 'foo');
251cb0ef41Sopenharmony_ci      }, 200);
261cb0ef41Sopenharmony_ci    });
271cb0ef41Sopenharmony_ci  });
281cb0ef41Sopenharmony_ci}, 100);
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_cisetTimeout(() => {
311cb0ef41Sopenharmony_ci  asyncLocalStorage.run(new Map(), () => {
321cb0ef41Sopenharmony_ci    const store = asyncLocalStorage.getStore();
331cb0ef41Sopenharmony_ci    store.set('hello', 'earth');
341cb0ef41Sopenharmony_ci    setTimeout(() => {
351cb0ef41Sopenharmony_ci      assert.strictEqual(asyncLocalStorage.getStore().get('hello'), 'earth');
361cb0ef41Sopenharmony_ci    }, 100);
371cb0ef41Sopenharmony_ci  });
381cb0ef41Sopenharmony_ci}, 100);
39